External Binary Search
Ah, binary search—one of the classic algorithms of computer science lore. (I covered it way back in Volume 1, Chapter 2.) It’s a super-fast algorithm, clocking in at a blazing O(log N).
The typical binary search deals with data that is small enough to fit inside main memory. But what would binary search look like when applied to external memory? That is, say we had an ordered list stored in the filesystem, but the list is too large for RAM. How might we perform binary search?
Perhaps the most straightforward approach would be to perform binary search on blocks of data. Let’s visualize this.
Say that we have an ordered file that contains 20 values, and our computer’s block size is 4. This means that we have 5 distinct ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access