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)?

  1. A. 64
  2. B. 108
  3. C. 23
  4. 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

Exams that ask this topic