Data Structures & AlgorithmsModerateProduct-company MCQ pattern
In how many ways can 10 be made from coins of 2, 3 and 5 (unlimited supply, order does not matter)?
- A. 6
- B. 4
- C. 5
- D. 3
Correct answer: B. 4
The combinations are 2+2+2+2+2, 2+2+3+3, 5+5 and 2+3+5, so 4. Counting ordered sequences (permutations) would give a much bigger number; the DP loops over coins outside and amounts inside to avoid that.
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
- 0/1 knapsack, capacity 7. Items (weight, value): (1, 1), (3, 4), (4, 5), (5, 7). What is the maximum total value?
- Matrices A (10 × 20), B (20 × 30) and C (30 × 40) are to be multiplied. What is the minimum number of scalar multiplications?
- What is the length of the longest strictly increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7]?
- AVL tree: keys 30, 10, 20 are inserted in that order into an empty tree. What rebalancing happens, and what is the root afterwards?
- What is the minimum number of nodes in an AVL tree of height 4 (a single node has height 0)?
- How many different spanning trees does the complete graph K₄ have?