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

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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