ProgrammingModerateCognizant GenC · Capgemini

Consider the function. f(n): if n <= 1 return n if n mod 2 == 0 return f(n / 2) + 1 return 2 * f(n - 1) + 1 What is f(13)?

  1. A. 14
  2. B. 15
  3. C. 16
  4. D. 13

Correct answer: B. 15

f(2)=2, f(3)=2*2+1=5, f(6)=6, f(12)=7, f(13)=2*7+1=15.

More Pseudocode and Code Tracing questions

Exams that ask this topic