Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 9 - Database Systems - Section 9.5 - Traditional File Structures - Questions & Exercises - Page 446: 2

Answer

(If an odd number of files occurs at any stage of this process, we need merely to set the odd one aside and pair it with one of the larger files in the next stage.

Work Step by Step

The idea is to first divide the file to be stored into many separate files containing one record each. Next, group the one-record files into pairs, and apply the merge algorithm to each pair. - This results in half as many files, each with two records. Furthermore, each of these two-record files is sorted. We can group them into pairs and again apply the merge algorithm to the pairs. Again we find ourselves with fewer but larger files, each of which is sorted. Continuing in this fashion, we are ultimately left with only one file that consists of all the original records but in sorted order. (If an odd number of files occurs at any stage of this process, we need merely to set the odd one aside and pair it with one of the larger files in the next stage.)
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.