O(n log n) is the lower bound for comparison-based sorting

Ever wonder why sorting can't be faster than a certain point?

Image: The Government of the Grand-Duchy of Luxembourg, Public domain, via Wikimedia Commons

O(n log n) is the lower bound for comparison-based sorting

Ever wonder why sorting can't be faster than a certain point?

Imagine you're organizing a bookshelf by height, but you can't compare books directly. You need to know the height of each book to place them correctly.

You're limited by how many times you can compare books to figure out their order. There's a minimum number of comparisons needed to sort them all.

Example

If you have 8 books and compare them in pairs, you might need up to 7 comparisons to sort them all.

Remember this

The lower bound for sorting is O(n log n) comparisons.

Related concepts

Swipe through 100 ML concepts daily

Open Pocket Polymath