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

  Choose three or more types of testing

Write down the discussion as if you are the systems analyst briefing your CIO as the two of you are walking over to the steering committee meeting in which a "go/no go" decision will be made whether to go live with your new enterprise system (this..

  Develop a gui application that includes a text area

Develop a GUI application that includes a text area, 5 buttons, and a keyboard.

  Define current and emerging nonvolatile ram technologies

List and explain current and emerging nonvolatile RAM technologies. What advantages are potentially offered by the emerging technologies as compared to current flash RAM technology?

  Find the instruction format for each instruction

Using the MIPS program including bugs, determine the instruction format for each instruction and the hexadecimal values of each instruction field.

  Discussing the challenges of security

Recognize and discuss one of the challenges of the security and three vulnerabilities that are associated with use of the wireless network.

  How can translate into the broader area of business ethics

What responsibility do computing professionals have to society at large and to other members in their profession.how can translate into the broader area of business ethics.

  What elements did the new world view possess

What elements did the new world view possess that were to enable it to last until the "Idea of Progress" in the eighteenth century. Is it still part of who we still think we are today Does it still define our place in the cosmos

  In the it field group projects often have strict deadlines

groups will be assigned no later than the end of unit 1. if you wish to be involved in a project-managed group please

  They want ot add calculation of shipping and tax

Each step takes 7 days except mail, that is the next day after personalize.

  Write down a shell program

-Check if there is exactly 2 filenames, if not, printout error message

  How to use the same naming conventions

how to use the same naming conventions and that their programs work together even though they are created independently.

  Design a combinational logic circuit

Design a combinational logic circuit that displays the hexadecimal value of a gray code input according to the specifications.

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