Data Structures & AlgorithmsHardTCS NQT · GATE CS

Assertion (A): The greedy 'largest coin first' is optimal for the coin set {1, 3, 4} when the amount is 6. Reason (R): A coin system whose denominations are each a multiple of the previous one (such as 1, 5, 25) is canonical, and greedy is optimal for canonical systems.

  1. A. Both A and R are true, and R explains A
  2. B. A is true, but R is false
  3. C. A is false, and R is true but does not apply to this coin set
  4. D. Both A and R are false, and R is true only for coin sets of size two

Correct answer: C. A is false, and R is true but does not apply to this coin set

Greedy gives 4 + 1 + 1 = 3 coins for 6, while 3 + 3 uses 2, so A is false. R is a true property of canonical systems, but {1, 3, 4} is not a chain of multiples, so R does not apply.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic