Similar questions 1 more →
Greedy Algorithms

Select all that apply
Answer & solution
Answer: A: 165 (no official key was published)
Always merge the two shortest remaining files, as in the optimal merge/Huffman construction. Merge5+10=15, costing 15; then 15+15=30, costing 30; then 20+25=45, costing 45; finally 30+45=75, costing 75. Total cost is 15+30+45+75=165. The greedy choice is optimal because two smallest weights can occupy deepest sibling leaves of an optimal merge tree, after which contracting them leaves the same problem on fewer files. Counting only 75 ignores repeated moves through intermediate merges.