Prove RSelect runs in expected O(n) even with adversarial input
Analyze the prove rselect runs in expected o(n) even with adversarial input.
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Consider how the random selection of the pivot affects the partitioning step in rselect, and how this randomness helps in achieving the expected linear time complexity even with adversarial inputs.
Analyze the recurrence relation for rselect's expected running time, and use the linearity of expectation to show that the expected time is O(n) by considering the probability distribution of the pivot's rank.
Prove that the probability of the pivot being "good" (i.e., splitting the array into two parts with a constant fraction of elements) is at least 1/2, and use this to derive the expected running time of rselect using the master theorem or recursion tree method.
Prove RSelect runs in expected O(n) even with adversarial input
Analyze the prove rselect runs in expected o(n) even with adversarial input.