Data Structures & AlgorithmsHardGATE CS · ICPC regional
Coins of denominations [11, 9, 8, 3] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 28? (Coins may be used any number of times; the answer must sum exactly.)
- A. 5
- B. 28
- C. 3
- D. 4
Correct answer: C. 3
The unbounded DP gives 3 coins. The greedy largest-first rule uses 4, which is the trap when denominations are not canonical.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Distinct words ['caab', 'ac', 'aa', 'c', 'baab', 'bbb', 'bbca'] are inserted into an empty trie (one node per character, shared prefixes…
- On an 6 × 6 chessboard with rows and columns numbered 0 to 5, a knight starts at (2, 5) and must reach (0, 0) (as (row, column)). A knight…
- Complete undirected graph on vertices A to F with symmetric edge weights given row by row (row i, column j = weight of edge between…
- Bipartite graph with left side {A, B, C, D}, right side {E, F, G, H} and edges A–E, B–E, B–H, C–E, C–F, C–G, C–H, D–E. What is the size of…
- Distinct words ['bbba', 'aaa', 'bcaa', 'aac', 'b'] are inserted into an empty trie (one node per character, shared prefixes sharing nodes…
- A binary tree with distinct letters has preorder ACDEBF and inorder DEBCAF. What is its postorder traversal (left, right, root), written…