Data Structures & AlgorithmsModerateProduct-company MCQ pattern

How many calls in total (including the first) does C(5, 2) make?

How many calls in total (including the first) does C(5, 2) make?
int C(int n, int k) {
    if (k == 0 || k == n) return 1;
    return C(n - 1, k - 1) + C(n - 1, k);
}
  1. A. 20
  2. B. 15
  3. C. 10
  4. D. 19

Correct answer: D. 19

The leaves of the recursion tree each return 1 and add up to C(5, 2) = 10, so there are 10 leaves; every internal call has exactly 2 children, so internal calls = 10 − 1 = 9. Total 19. 10 is the value, not the call count.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic