4 Selection Algorithm (10 points, after Lec5)
(a) As we have learned in the lecture, partition takes O(n) time complexity. In terms of random
selection algorithm, when will we encounter the worst-case scenario? What is the worst-case
runtime for random selection algorithm? Is this related to input sequence? (3 points)
(b) Do we have a sequence of input which guarantees that it can have the best-case runtime for
random selection algorithm? What is the best-case runtime for random selection algorithm? (2
points)
(c) Deterministic selection algorithm guarantees its runtime to be O(n) for every input array of
length n. Given the assumption that there exists a positive constant e that satisfies:
i) T(1) ? c
ii) T(n) ? cn + T(\frac{n}{5}) + T(\frac{7n}{10})
Then prove that T(n) = O(n). (Please clearly show your steps in detail) (5 points)
Solution: