27
Worst-case analysis For the worst case, we can write the recurrence equation as We guess that

28
Worst-case analysis This expression achieves a maximum at either end points: q=0 or q=n-1. Using the maximum of T(n) we have Thus This expression achieves a maximum at either end points: q=0 or q=n-1.

29
Worst-case analysis We can also show that the recurrence equation as Has a solution of We guess that

30
Worst-case analysis Using the maximum of T(n) we have We can pick the constant c 1 large enough so that and Thus the worst case running time of quicksort is

58
Calculating Expectation(Alternative approach) Let X be the total number of comparisons performed in all calls to PARTITION. Let being the ith smallestelement of the array A. We define the set Let also

59
Calculating Expectation(Alternative approach) To determine the prob. that and are ever compared, we note that the values will initially in the same bracket and will remain in the same bracket if the number chosen for the first comparison is not between and. For example, if the comparison number is larger than, then all the values will go in a bracket to the left of the comparison number, and if it is smaller than, then they will all go in a bracket to the right. Thus all the values will remain in the same bracket until the first time that one of them chosen as a comparison value. At that point all the other values between i and j will be compared with this comparison value. If this comparison value is neither i or j then when compared with it, i will go into a left bracket and j will go into right bracket, consequently i and j will never be compared. If the comparison value of the set is either i or j then there will be a direct comparison between i and j.

60
Calculating Expectation(Alternative approach) The total number number of comparison performed by the algorithm

About project

Feedback

To ensure the functioning of the site, we use cookies. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy &amp Terms.
Your consent to our cookies if you continue to use this website.