In the final step, the algorithm simultaneously merges the ten blocks into one large merged index. An example with two blocks is shown in Figure 4.3, where we use di to denote the ith document of the collection. To do the merg- ing, we open all block files simultaneously, and maintain small read buffers for the ten blocks we are reading and a write buffer for the final merged in- dex we are writing. In each iteration, we select the lowest termID that has not been processed yet using a priority queue or a similar data structure. All postings lists for this termID are read and merged, and the merged list is written back to disk. Each read buffer is refilled from its file when necessary.