What is the time complexity of quicksort?

What is the time complexity of quicksort?

Approach: Analyze average and worst-case scenarios.

Average case O(n log n). Worst case O(n^2) when the pivot consistently results in highly unbalanced partitions.

Follow-up: How can you improve the worst-case performance?

Key concepts: pivot selection, recursion, partitioning.