Question

In: Computer Science

What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it....

What is the average performance of Quicksort assuming every input permutation is equally likely? Prove it.

Hint: In this case pivot(split) element very likely to provide good balance during partition.

Solutions

Expert Solution

Let T(n) be the time needed for n input.

Pivot position i(belongs to) {0,1,2,...,n-1}

Let time for partitioning is kn (k is constant)

Let the pivot position be i then we can partition the array into 2 subarrays, one containing i elements and n-1-i elements

Average run time

         

.......(1)

Again using the recurrence relation we have

......(2)

Subtracting (1)-(2)

Therefore

Dividing by n(n+1)

Using this we write

........

_______________________________________

(Adding all these)

                              Hn is the nth harmonic number   

                

Thus


Related Solutions

Assuming that boy and girl babies are equally​ likely, what would be​ Kathy's probability of having...
Assuming that boy and girl babies are equally​ likely, what would be​ Kathy's probability of having at most three daughters if she were to have four children​ altogether? (You may want to use a tree diagram to construct the sample​ space.)
There are 36 students in the classroom. Assuming each date of the year are equally likely...
There are 36 students in the classroom. Assuming each date of the year are equally likely to be the birthday of a student. Calculate the probability that there are at least two students having the same birthday. use probability and stats to solve
A fund manager wants to know if it is equally likely that the Nasdaq Average will...
A fund manager wants to know if it is equally likely that the Nasdaq Average will go up each day of the week. For each day of the week, the fund manager observes the following number of days when the Nasdaq Average goes up. Day of the Week Observed Monday 192 Tuesday 189 Wednesday 202 Thursday 199 Friday 218 For the goodness-of-fit test, the null and alternative hypotheses are ________. H0: p1 = p2 = p3 = p4 = 1/4,...
. Assuming each choice is equally likely to occur, what is the probability that he gets at least one bar of each type?
A man goes to the store to buy seven candy bars. The store sells five different types of candy. Assuming each choice is equally likely to occur, what is the probability that he gets at least one bar of each type?
What is the running time of Quicksort when the input array is sorted in ascending order?...
What is the running time of Quicksort when the input array is sorted in ascending order? (please explain in detail)
This question concerns the case of two input sequences. Prove that every algorithm that outputs all...
This question concerns the case of two input sequences. Prove that every algorithm that outputs all longest common subsequences of two input sequences has a worst-case running time that is exponential. To do so, show how to define, for every positive integer n, two length-n sequences Xn, Yn with lower bound (c^n) different longest common subsequences, where c>1 is a constant. You are allowed to use an alphabet of size n, i.e., the symbols in Xn, Yn can come from...
We distribute 15 books among four students so that all allocations are equally likely. What is...
We distribute 15 books among four students so that all allocations are equally likely. What is the probability that a. the first student gets at least 2 books? b. the first or the last student gets at least two books? c. no one gets less than three books?
(a) A poll of 2,291 likely voters was conducted on the president’s performance. Approximately what margin...
(a) A poll of 2,291 likely voters was conducted on the president’s performance. Approximately what margin of error would the approval rating estimate have if the confidence level is 95%? (Round your answer to 4 decimal places.) Margin of error (b) The poll showed that 46 percent approved the president’s performance. Construct a 90 percent confidence interval for the true proportion. (Round your answers to 4 decimal places.) The 90% confidence interval to (c) Would you agree that the percentage...
(a) A poll of 2,277 likely voters was conducted on the president's performance. Approximately what margin...
(a) A poll of 2,277 likely voters was conducted on the president's performance. Approximately what margin of error would the approval rating estimate have if the confidence level is 95%? (Round your answer to 4 decimal places.) Margin of error              (b) The poll showed that 44% approved the president's performance. Construct a 90% confidence interval for the true proportion. (Round your answer to 4 decimal places.) The 90% confidence interval is from     to    .
1. What is a monotone class? 2.Prove that every algebra or field is a monotone class...
1. What is a monotone class? 2.Prove that every algebra or field is a monotone class Proof that 1. show that the intersection of any collection of algebra or field on sample space is a field 2. Union of field may not be a field
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT