Expected comparisons for randomized QuickSort on length n
Analyze the expected comparisons for randomized quicksort on length n.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Recall that randomized quicksort selects a pivot uniformly at random in each recursive call, making the expected behavior independent of input order.
Consider the recurrence relation for expected comparisons: E(n) = n-1 + (1/n) * Σ(E(i) + E(n-1-i)) for i from 0 to n-1.
Use linearity of expectation to model the probability that any pair of elements is compared during the sorting process, then sum these probabilities to derive the expected total comparisons.
Expected comparisons for randomized QuickSort on length n
Analyze the expected comparisons for randomized quicksort on length n.