Sorting algorithm

How fast can you find a book in a library without a map?

Sorting algorithm

How fast can you find a book in a library without a map?

Imagine you're looking for a specific book in a library without any organization. You'd have to check each shelf one by one, which can take forever, especially if the library is huge.

Think of the library as a list. Instead of checking each shelf (or list item) one by one, you split the library in half and eliminate half of the shelves each time, narrowing down where your book might be.

Example

If you have 1024 books, instead of checking all 1024 shelves, you check 512, then 256, then 128, and so on, until you find your book.

Remember this

This method, called binary search, drastically reduces the time it takes to find something in a large, unsorted list.

Related concepts

Swipe through 100 ML concepts daily

Open Pocket Polymath