Ask Question
24 December, 13:41

Assuming that a query has a buffer holding up to 3 blocks, and each block can hold two records. Use merge-sort to sort the following records in ascending order: 10, 11, 1, 5, 90, 1, 2, 101

How many runs will be produced in the whole algorithm and what are the contents of the runs?

+5
Answers (1)
  1. 24 December, 14:27
    0
    a) 5 runs will be generated.

    b) Since the buffer can hold 3 records, the first 3 runs are (1, 10, 11), (1, 5, 90) and (2, 10). Then we need to reserve one block as output buffer, the algorithm can merge two runs at most at the same time. As a result, we can choose to merge the first two runs into a larger one: (1,1,5,10,11,90), which is merged with the run (2, 10) to generate the final output.

    Explanation:

    5 runs will be generated.

    Since the buffer can hold 3 records, the first 3 runs are (1, 10, 11), (1, 5, 90) and (2, 10). Then we need to reserve one block as output buffer, the algorithm can merge two runs at most at the same time. As a result, we can choose to merge the first two runs into a larger one: (1,1,5,10,11,90), which is merged with the run (2, 10) to generate the final output.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assuming that a query has a buffer holding up to 3 blocks, and each block can hold two records. Use merge-sort to sort the following ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers