However, quicksort is O(N^2) in pathological cases. Recent versions of the C++ library therefore use introsort, a version of quicksort that watches whether the recursion is getting too deep, and if so it switches to heapsort, which is O(n log n) in the worst case. This makes introsort O(n log n) in all cases without incurring the greater overhead of heapsort in every case.
Introsort is almost as old as Java. Maybe some day Java will catch up.

]]>