Write the recurrence for the worst-case runtime

Assignment Help Computer Engineering
Reference no: EM131263030

Problem Set

1. [6] Here is a version of binary search that returns the index of the element if it is found, or -1 if the element is not found.

1 def binary_search (A , x ):

2 '''

3 Pre : list A is sorted in ascending order and has no duplicate elements

4 Post : return the index of x in A if exists ; return -1 otherwise .

5 '''

6 if len ( A ) == 0:

7 return -1

8 m = len ( A )//2

9 if A [ m ] == x :

10 return m

11 elif A [ m ] > x :

12 return binary_search ( A [0.. m -1] , x )

13 else :

14 result = binary_search ( A [ m +1.. len ( A ) -1] , x )

15 if result == -1:

16 return -1

17 else :

18 return result + m + 1

(a) Write the recurrence for the worst-case runtime T(n) of the algorithm, and use the master theorem to find the asymptotic upper-bound on T(n). State clearly which case of the master theorem applies.

(b) Prove that this algorithm is correct.

2. Below is the mystery algorithm that we worked on in Problem Set.

1 def mystery ( lst ):

2 if len ( lst ) <= 1:

3 return

4 if lst [0] > lst [ -1]:

5 lst [0] , lst [ -1] = lst [ -1] , lst [0]

6 if len ( lst ) >= 3:

7 split = len ( lst ) // 3

8 mystery ( lst [0.. len ( lst ) - split - 1])

9 mystery ( lst [ split .. len ( lst ) - 1])

10 mystery ( lst [0.. len ( lst ) - split - 1])

We analyzed that the recurrence of the worst-case runtime of this algorithm is the following.

Some students have already realized that this algorithm is in fact a sorting algorithm. So in this problem set we will formalize our understanding of this interesting sorting algorithm.

(a) Find the asymptotic upper-bound on the worst-case runtime of mystery using the master theorem. State clearly which case of the master theorem applies.

(b) State the proper precondition and postconditi on for the mystery function. Note: "proper" precondition means that it is necessary and sufficient for the algorithm to work correctly. In particular, don't add unnecessary conditions.

(c) Prove that mystery is correct according to the precondition and postcondition that you specified in (b). Note: Be careful when finding the possible program paths, and state clearly which lines of code are executed for each program path (use the line numbers).

Assignment - Please follow all the instructions and write step by steps

https://www.cs.toronto.edu/~ylzhang/csc236/files/ps6.pdf

Lecture Notes

https://www.cs.toronto.edu/~ylzhang/csc236/files/lec07-master-theorem-correctness.pdf

https://www.cs.toronto.edu/~ylzhang/csc236/files/lec08-loop-invariant.pdf

Reference no: EM131263030

Questions Cloud

Explain the descriptions of generations from traditionalists : Analyze the descriptions of generations from traditionalists to Generation. Assess your own category and discuss the ways you agree and differ from the description, indicating which generation best describes you.
Provide 2 rn interventions for each goal that you developed : Provide 2 RN interventions for each goal that you developed in #1. Provide rationale for each intervention being performed by an RN. Short term goals can usually be achieved by the end of your shift. Long term goals are usually achieved by discha..
Arise in the field of human resource : The textbook identified several issues that arise in the field of human resource (HR) management. Sum up the responsibility of HR management to address and solve these problems.
The investing activities section of statement of cash flows : During Benson most recent fiscal year, beginning plant assets, net of depreciation totaled $150,000 and the ending plant assets totaled $187,500. How much will be reported as cash received from the sale of equipment in the investing activities sectio..
Write the recurrence for the worst-case runtime : CSC236 - Problem Set. Write the recurrence for the worst-case runtime T(n) of the algorithm, and use the master theorem to find the asymptotic upper-bound on T(n). State clearly which case of the master theorem applies
Examples of best practices an organization : Discuss and provide examples of best practices an organization can implement to leverage diversity in areas such as group management, recruiting, hiring, retention, and development practices to increase an organization's competitive advantage.
What is the difference between a mediator and an arbitrator : What is the primary reason for your personal conflicts? Your work conflicts? - What is meant by "ownership of the problem"?
Calculate break-even point in number of passenger flights : Comfi Airways, Inc., a small two-plane passenger airline, has asked for your assistance in some basic analysis of its operations. Both planes seat 10 passengers each, and they fly commuters from Comfi’s base airport to the major city in the state, Me..
Prepare a persuasive proposal report : You're company specializes in providing state of the art computer based networking systems to other companies as a way of keeping them in touch with modern technologies in the work place.

Reviews

len1263030

11/2/2016 4:40:54 AM

Answer each question completely, always justifying your claims and reasoning. Your solution will be graded not only on correctness, but also on clarity. Answers that are technically correct that are hard to understand will not receive full marks. Mark values for each question are contained in the [square brackets]. You may work in groups of up to THREE to complete these questions.

Write a Review

Computer Engineering Questions & Answers

  What are the advantages of using the scsi devices

What will be different about performing a hard-drive-to-tape backup with IDE devices and with SCSI devices? What are the advantages of using SCSI devices over IDE devices for the backups.

  Sense making in health care organizations

Evaluate the most suitable way that the “sense making” may be applied to the health care organizations. Give the specific examples in order to support your response.

  Which choices would made and why

Using SMIL and SVG, it is possible to choose resources from different locations and contributors to create a single unified presentation

  Next generation technology grants access based on human

next generation technology grants access based on human attributes?

  Show the mortgage payment amount

Write down a program in Java (without graphical interface) using a loan amount of $200,000 with an interest rate of 5.75% and a 30 year loan. Display the mortgage payment amount and then list the loan balance and interest paid for each payment ove..

  Questionlets make a discussion prevalence of project

questionlets make a discussion prevalence of project failure. think of or find cases of a project that didnt have the

  Octal and binary the mayan number

Convert to base hex, decimal, octal and binary the Mayan number (base 20) J7GE.I8H (all done in arithmetic in decimal)

  What advice or guidance would offer a company

In times of financial difficulty, companies often resort to trimming the human asset base, without proper prior analysis of the long-term impacts of those actions.

  Define four phases of an information system''s life cycle

What are the 4 phases of an information system's life cycle? The business process of building and managing information system has four phases. These phases apply to all information systems although different systems may be acquired using different..

  Compares and contrasts linux server and linux workstation

Your company is currently investigating the use of Linux. Your manager has asked you to research the feasibility of using Linux in both the server and workstation environments. Your manager would like to see an 8- to 10-page paper that:

  You have been recently hired to help with purchasing

you have been recently hired to assist with purchasing computer forensics tools and resources for a major corporation.

  What is the average access time of the resulting system

Determine the memory interleaving factor required to obtain an avarage access time that 60 ns given that the main memory has an access time of 100 ns and the cach has an accesd time of 20 ns. What is the average access time of the resulting system..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd