Explain how quicksort works
Quicksort is an efficient, divide-and-conquer sorting algorithm that works by selecting a pivot, partitioning the array around the pivot, and recursively sorting the subarrays. It typically has an average-case time complexity of O(n log n) but can degrade to O(n^2) in the worst case if the pivot selection is poor. Despite this, it remains popular due to its average efficiency and simple implementation.