Algorithms

Sorting Efficiency

Which sorting algorithms are fastest and slowest, and how Timsort, quicksort and selection sort compare.

Is Selection Sort Always O(n²)?

For the standard version, yes: selection sort always does about n²/2 comparisons, so its running time is O(n²) for any input order, including sorted lists.

2 min read

Is Timsort Faster Than Quicksort?

On random data, Timsort is usually not faster than quicksort. On data with existing runs, it can be faster, and its worst case is O(n log n), unlike quicksort's O(n²).

2 min read

Related topics

More in algorithms