The following C function is an example of what type of recursion? int f(int n)…
2023
The following C function is an example of what type of recursion?
int f(int n) { if(n==1) return 1; else if(n==0) return 0; else return(f(n-1)+f(n-2)); }
- A.
Binary
- B.
Tail
- C.
Linear
- D.
Head
Attempted by 191 students.
Show answer & explanation
Correct answer: A
The function calls itself twice, as f(n-1) and f(n-2), for the recursive case. A recursion with two recursive calls is binary recursion.