Quicksort is a divide-and-conquer algorithm that works by partitioning an array into two subarrays such that elements in one subarray are less than the elements in the other. It then recursively sorts the subarrays. The average runtime is O(n log n) but the worst case is O(n^2) when the array is already sorted. Randomizing the pivot selection results in an expected runtime of O(n log n) for all cases.