GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Eight files of sizes 4, 7, 9, 12, 15, 18, 22 and 25 are merged using 3-way merges (merging any 3 files costs the sum of their sizes; merge results can be merged again). What is the minimum total cost of merging them into one file?
- A. 244
- B. 210
- C. 274
- D. 320
Correct answer: B. 210
With k = 3, the number of leaves must satisfy (n − 1) mod (k − 1) = 0; since 7 mod 2 = 1, add one dummy file of size 0 and then merge the 3 smallest each time: cost 210. Merging without the dummy costs 244, and binary merging of the same files costs 320.
More Algorithms questions
- Which of the following statements about Huffman coding on a set of symbols with positive frequencies is/are correct? I. If f(a) > f(b)…
- Intervals (start, end, weight) are (0,3,4), (1,5,6), (2,6,10), (5,8,7), (4,9,9), (7,10,3), (9,12,8), (8,13,5), (12,15,6), (10,16,12); two…
- Ten unit-time jobs have (deadline, profit): (2,95), (1,60), (2,40), (3,85), (3,30), (1,25), (4,70), (2,20), (4,55), (5,15). Each job takes…
- Seven keys have search probabilities (in percent, in sorted key order) 18, 6, 22, 14, 4, 20, 16 and only successful searches occur. The…
- The egg-drop puzzle: a building has 100 floors, and you have 3 identical eggs. An egg that is dropped from a floor at or above the…
- A building has 100 floors and you have 2 identical eggs; an egg breaks when dropped from the critical floor or above, and a broken egg…