CS FundamentalsVery hardGATE CS

A file of 32,000 pages is sorted with an external merge sort using 32 buffer pages: pass 0 produces sorted runs of 32 pages, and every merge pass merges as many runs as possible (one buffer page is kept for output). Counting a read plus a write of every page in every pass (including pass 0), how many page I/Os are performed in total?

  1. A. 192,000
  2. B. 320,000
  3. C. 128,000
  4. D. 256,000

Correct answer: D. 256,000

Pass 0 yields 1000 runs. With 32 buffers the merge fan-in is 31, so the runs shrink 1000 -> 33 -> 2 -> 1: 3 merge passes. Total passes = 1 + 3 = 4 and I/Os = 2 x 32,000 x 4 = 256,000. A fan-in of 32 would give only 3 passes in all.

More DBMS and SQL questions

Exams that ask this topic