(c)
• Assume that pj is the probability that A[k] is the jth biggest element. 1 ≤ j ≤ n
• pj=1/n so that any component inside the array A could be the jth biggest.
• Also, when the pivot element A[k] is the jth biggest element, suppose Tj is the estimated running time.
• Then total assumption running time,
• When the pivot element A[k] is the jth largest, then ALhas at most n-j+1 and ARhas at most
• j-1 elements.
• ThusTj is at most T(n-j+1) + T(i-1) +O(n) .
Hence ------(1)
To show that T(n) = O(n log n), use induction.
Assume T(n) = O(n log n) implies T(n) ≤ bn log n ------(2)
Re write equation(1) as follows:
From inductive hypothesis(equation(2)),
Again, re write above in equation as follows:
Therefore, by induction, it is proved that the solution has run time of .