Lower bound: Can we sort faster than \Omega(n \log n) time?
Theorem
Any comparison-based sorting algorithm for sorting n elements must make at least \Omega(n \log n) comparisons in the worst case.
Observation
Any binary tree of height T(n) has at most 2^{T(n)} leaves.
2^{T(n)} \geq n! \implies T(n) \geq \log_2(n!)
Using Stirling’s approximation: n! \approx \sqrt{2\pi n}(\frac{n}{e})^n T(n) \geq \log_2\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\right) = \log_2(\sqrt{2\pi n}) + n\log_2 n - n\log_2 e \in \Omega(n\log_2 n)
Problem
Quicksort Algorithm:
Quicksort Algorithm
Instead of always picking the first or last element as the pivot, we pick a random element from the array.
Randomized-Partition: - Randomization eliminates dependence on input order. - No single input can guarantee worst-case behavior.
Let T(n) be the worst-case time for QUICKSORT on an input of size n.
We have the recurrence: T(n) = \max_{0 \leq q \leq n-1} (T(q) + T(n-q-1)) + \Theta(n)
Q: How bad can T(n) be?
A: \Omega(n^2).
Let’s assume the input is sorted in increasing order.
Choosing the highly unbalanced split (q = 0): T(n) \geq T(0) + T(n-1) + dn \quad (\text{for some constant } d > 0) \geq T(n-1) + dn \quad (\text{since } T(0) \geq 0)
Unrolling this recurrence: T(n) \geq \sum_{i=1}^n di = d \frac{n(n+1)}{2} \in \Omega(n^2)
Thus, worst-case complexity of Quicksort is: T(n) = \Omega(n^2)
CS F364: Design & Analysis of AlgorithmsTulasimohan Molli