Data Structures & AlgorithmsModerateProduct-company MCQ pattern

Coins of 1, 5, 6 and 8 are available in unlimited supply. For amount 11, how many coins does the 'largest coin first' greedy method use, and how many does the optimal (DP) solution use?

  1. A. Greedy 4, optimal 3
  2. B. Greedy 3, optimal 2
  3. C. Greedy 2, optimal 2
  4. D. Greedy 4, optimal 2

Correct answer: D. Greedy 4, optimal 2

Greedy takes 8, then 1 + 1 + 1: 4 coins. DP finds 5 + 6 = 11 with 2 coins. Greedy is only guaranteed optimal for canonical coin systems like 1, 2, 5, 10.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic