Computer Science EngineeringVery hard

For void f(int n){ if(n>0){ f(n-1); printf("%d ",n); f(n-1); } }, how many numbers are printed by the call f(4)?

  1. A. 8
  2. B. 15
  3. C. 16
  4. D. 31

Correct answer: B. 15

Let P(n)=2P(n-1)+1 with P(0)=0, which gives 1, 3, 7, 15.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic