Recursion questions

Q38

GATE CS 2015 CS-3RecursionMCQ2 marks−2/3 if wrong
Consider the following recursive C function.
void get(int n)
{
    if (n<1) return;
    get(n-1);
    get(n-3);
    printf("%d", n);
}
If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main()?
Show answer without attempting

Answer: B

Q24

GATE CS 2015 CS-2RecursionNAT1 mark
Consider the following C function.
int fun(int n){
    int x=1, k;
    if (n==1) return x;
    for (k=1; k<n; ++k)
        x = x + fun(k) * fun(n-k);
    return x;
}
The return value of fun(5) is _________.
Show answer without attempting

Answer: 51

0/20 correct0 marks

Related topics in Programming and Data Structures