GATE Computer ScienceEasyGATE CS (PYQ pattern)

A coin system has denominations {1, 5, 10, 20, 25}. The greedy algorithm (always take the largest coin that fits) first gives a non-minimum number of coins for which smallest amount?

  1. A. 40
  2. B. 30
  3. C. 35
  4. D. 45

Correct answer: A. 40

For 40 greedy picks 25 + 10 + 5 (3 coins) while 20 + 20 uses 2. Amounts 30 (25 + 5) and 35 (25 + 10) are optimal, and a check of every smaller amount confirms 40 is the first failure.

More Algorithms questions

Exams that ask this topic