[prev] 11 [next]

Cost of Two-way Merge Sort

For a file containing b data pages:
  • require ceil(log2b) passes to sort,
  • each pass requires b page reads, b page writes
Gives total cost:   2.b.ceil(log2b)

Example: Relation with r=105 and c=50     b=2000 pages.

Number of passes for sort:   ceil(log22000)  =  11

Reads/writes entire file 11 times!    Can we do better?