C09-Medians-and-Order-Statistics/9.2.md
Show that in RANDOMIZED-SELECT, no recursive call is ever made to a 0-length array.
Answer答案很明显,假如划分的一边数组是空的,那么这个if语句条件是不会成立的,这个调用是不会被call的.
It is obvious, if the array is empty, then the condition of if will not hold, it will definitely not be called.
Argue that the indicator random variable and the value T(max(k - 1, n - k)) are independent.
Answer不论取0还是1, T(max(k-1,n-k))是不会变的.
No matter is 0 or 1, T(max(k-1,n-k))will not change.
Write an iterative version of RANDOMIZED-SELECT.
Answercode tells everything!
Suppose we use RANDOMIZED-SELECT to select the minimum element of the array A = {3, 2, 9, 0, 7, 5, 4, 8, 6, 1}. Describe a sequence of partitions that results in a worst-case performance of RANDOMIZED-SELECT.
AnswerFollow @louis1992 on github to help finish this task.