Randomized Selection
Analyzing RandomizedSelect()
- Worst case: partition always 0:n-1
T(n) = T(n-1) + O(n) = ???
= O(n2) (arithmetic series)
- Worse than sorting!
- “Best” case: suppose a 9:1 partition
T(n) = T(9n/10) + O(n) = ???
= O(n) (Master Theorem, case 3)
- Better than sorting!
- What if this had been a 99:1 split?