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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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