555 views
1 votes
1 votes
Assume 5 buffer pages are available to sort a file of 105 pages. The cost of sorting using m-way merge sort is

1 Answer

0 votes
0 votes
In the first pass we can create [105/5]=21 sorted sub-files,each 5 pages long.In the second pass by 4-way merging (4 because one of the 5 available buffers has to be reserved for holding the output),one can create [21/4]=6 sorted sub-files,each 20 pages long (except the last).
Again applying 4-way merge sort,we get create [6/4]=2 sorted sub-files.
 These two can be merged to get the final sorted file.
We need a total of 4 passes.
Total cost will be 2 x 105 x 4=840 units.

Related questions

4 votes
4 votes
1 answer
1
Shivi rao asked Oct 10, 2017
1,545 views
True or FalseMerge sort on Linked list takes O(nlogn)
3 votes
3 votes
3 answers
2
srestha asked Jan 4, 2017
3,765 views
Consider the following statement:S1: Merge sort on linked list take O(n log n) time to sort input of length n.S2: Merge sort on linked list give better space complexity t...
0 votes
0 votes
0 answers
3
Ujjal Das asked Mar 17
135 views
Calculate the minimum and maximum number of element comparisons involved in 2 way merge sort assuming n is power of 2.