ProgrammingHardGATE CS · Campus placements

C(0) = 1 and C(n) = sum over i from 0 to n-1 of C(i) * C(n-1-i). What is C(4)?

  1. A. 12
  2. B. 16
  3. C. 14
  4. D. 42

Correct answer: C. 14

C(1) = 1, C(2) = 2, C(3) = 5 and C(4) = 1*5 + 1*2 + 2*1 + 5*1 = 14. This is the Catalan recurrence, which counts balanced bracket strings.

More C Programming questions

Exams that ask this topic