M/B-Way Mergesort
You’ve seen many useful and interesting things in this chapter, and now we’re going to put them all together. That’s right—it’s time to learn about the external-memory Mergesort algorithm of choice. It’s called M/B-Way Mergesort, and you’ll see soon where this algorithm gets its moniker.
Let’s set the stage. We’re back in a world where our data does not fit in RAM, so we need an external-memory approach for executing Mergesort.
Say that we have a list of 64 data elements, and that our computer has a block size of 4 and a RAM size of 16. We’ve seen this scenario before, and our previous approach, which we called Second-Attempt Mergesort, worked like this:
We had three phases, each of which performed 16 I/Os. This yielded 48 ...
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