What is the average case time complexity

Assignment Help Other Subject
Reference no: EM132466004

Assignment - Consider the algorithm below, which accepts an array data and an integer r and returns the rth smallest value in the array.

Input: data: array of integers

Input: n: size of data

Input: r: desired rank to search for; must be between 1 and n, inclusive

Output: rth smallest value in data; i.e., a value in data such that exactly r - 1 other values are smaller

1 Algorithm: FindRank(data, r)

2 if n = 1 then

3|return deta[1]

4 end

5 Let pivot be a randomly selected value in data

6 Partition data into values less than pivot and ≥ pivot, as in QuickSort

7 Insert the pivot in between the "small" and "large" parts of array

8 Let p be the new location of the pivot

9 if p = r then

10 | return pivot

11 else if p > r then

12 | return FindRank(data[1..p - 1], r)

13 else

14 | return FindRank(data[p + 1..n], r - p)

15 end

Instructions -

1. Prove that must be between 1 and the length of, inclusive, when line 14 is executed

2. Prove that this algorithm returns the smallest value in the array. You may assume that all elements of data are unique.

3. What is the average case time complexity for this algorithm to find the minimum value in an array of length; i.e., FindRank(data, 1)? You may assume that it takes Θ(1) time to generate a random number, and you may ignore the possibility that the minimum value is randomly selected to be the pivot.

Hint: consider how large the recursive call(s) will be on average.

Reference no: EM132466004

Questions Cloud

Identify how understanding of ais : How each of concepts will help you in appreciating the power of AIS. describe how they increased your appreciation and understanding of AIS.
Compare and contrast financial and managerial accounting : Compare and contrast financial and managerial accounting. how either financial accounting helps external stakeholders make informed decisions
Discuss the activities undertaken by the caspar ltd : Discuss the activities undertaken by the Caspar Ltd and Spooky Ltd in relation to the determination of which entity controls Ghosts Ltd.
What is the minimum iron ore price required : What is the minimum iron ore price required for 75% concentrate to achieve a 20% rate of return on capital the facts:CAPEX of mine $150 million
What is the average case time complexity : What is the average case time complexity for this algorithm to find the minimum value in an array of length; i.e., FindRank(data, 1)
Company free cash flows to the firm : McMahon Company manufactures SIM cards for cell phones. what are the company's free cash flows to the firm (FCFF) for the year ended December 31, 2017?
What is the cost of goods sold inventory cycle : What is the Cost of Goods Sold Inventory Cycle for this Sales Journal? How do you put together the Cash Receipts and Cash Payments Journal
What is the maximum price you should be willing to pay : 1) If you want to earn 10% percent, should you buy this stock? 2) What is the maximum price you should be willing to pay for the stock?
Statement of financial position of ww associates : The following is the statement of financial position of WW Associates as at 31 Dec 2016. Statement of financial position as at 31 December 2016 $

Reviews

Write a Review

Other Subject Questions & Answers

  How can you link assessment findings to intervention

How can you link assessment findings to intervention? How can assessment information be used to create effective educational programs for children age birth - 8 years with ASD?

  Discuss about the violence against women act

Violence Against Women Act (V.A.W.A.) -What is it and did it Positively Impact on Domestic Violence? Present a historical overview of what it is.

  Examine how your philosophy has evolved during your courses

Write a teaching philosophy that is at least 500 words. Then, examine how your philosophy has evolved during your courses of study in the M.Ed. program.

  Compare current training and selection criteria

Based upon research of your state of residence or home state compare current training and selection criteria against criteria covered in the ASIS guide.

  Explain the risk factors for developing osteoporosis

A 60-year-old woman has just been diagnosed with osteoporosis. She does not understand how this could be possible, as she has always been a milk drinker.

  Discuss congress passed which part of trumans fair deal

Which of the following statements about the 1948 presidential election is true, Congress passed which part of Truman's Fair Deal

  Overcoming various communication obstacles

What are five tips to overcoming various communication obstacles?

  How the policy proposal you selected may impact stakeholders

Explain how the policy proposal you selected may impact three major stakeholders within the health care system (e.g., consumers, insurers, hospital systems).

  Discuss types of information systems in an organization

There can potentially be many types of information systems in an organization, but the most fundamental information systems in an organization are.

  The conceptual frameworks of the ethical constructs

Introduce the conceptual frameworks of the ethical constructs of ethics, moral, or legal standards and the purpose of the paper.

  What are the main advantages and limitations of each

The chapter in your textbook introduces various graphs, charts, & plots. What the main advantages and limitations of each of these in terms of data exploration

  Disuss about the classification of criminal offenses

Identify the penalties (minimum to maximum) for each class of felony and misdemeanor crimes in Virginia.

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