AlgoFrames

Efficient sorting

Sorts that reach n log n or better, how to compare them and how real libraries sort.

  • Merge sort Merge sort splits the array in half, sorts each half recursively and merges the sorted halves. It always takes O(n log n) time and is…
  • Quick sort: partitioning and pivots Quick sort picks a pivot, partitions smaller values left and larger right, then recurses on both sides. It is fast in practice but O(n²)…
  • Counting sort Counting sort counts how often each key appears, turns the counts into positions with prefix sums, and places items stably. No comparisons…