Searching, Sorting & Selection

Answer & solution
Official answer: B
Worst-case pivots repeatedly leave one side with nearly every remaining element. Treat the constant-size side's cost as O(1), yielding T(n)=T(n−1)+Θ(n). Unrolling accumulates n+(n−1)+…+2=Θ(n²). A represents balanced splitting, C duplicates the large subproblem, and D omits one half of a balanced sort. Printed B uses T(1) for constant work.
Solution: The most unbalanced quicksort split leaves one nontrivial subproblem of size n−1 and constant base-case work, plus cn partition work. Hence the listed recurrence T(n)=T(n−1)+T(1)+cn, B, gives Θ(n²).



