GATE Computer ScienceModerateGATE CS (PYQ pattern)
In how many ways can 20 be written as a sum of exactly 4 positive integers, where order does not matter (parts may repeat)?
- A. 64
- B. 108
- C. 23
- D. 84
Correct answer: A. 64
Partitions of 20 into exactly 4 parts equal partitions of 20 − 4 = 16 into at most 4 parts; a DP p(n, k) = p(n − 1, k − 1) + p(n − k, k) gives 64. 108 counts at most 4 parts; 23 counts 4 distinct parts.
More Algorithms questions
- A tree on vertices 0–10 has weighted edges 0-1 (3), 1-2 (4), 1-3 (2), 3-4 (6), 3-5 (1), 5-6 (7), 0-7 (5), 7-8 (2), 2-9 (3), 9-10 (8). Its…
- Vertices 0–10 of the tree with edges 0-1, 1-2, 1-3, 3-4, 3-5, 5-6, 0-7, 7-8, 2-9, 9-10 carry weights w = 4, 7, 3, 9, 5, 2, 8, 6, 5, 4, 10…
- Five cities have symmetric distances d(0,1) = 9, d(0,2) = 14, d(0,3) = 23, d(0,4) = 17, d(1,2) = 11, d(1,3) = 19, d(1,4) = 26, d(2,3) = 8…
- The standard 2-approximation for Vertex Cover scans the edges in the order 0-1, 1-2, 2-3, 3-4, 4-5, 5-6, 1-4, 2-5 and, whenever an edge…
- Items 0.5, 0.7, 0.5, 0.2, 0.4, 0.2, 0.5, 0.1, 0.6 (in this order) are packed into bins of capacity 1 by Next-Fit, First-Fit and…
- Longest-Processing-Time-first scheduling puts jobs, in non-increasing order of length, on the currently least loaded machine. For jobs of…