Computer Sciences > Gate 2017 Set-1 > C Programming
Consider the C functions foo and bar given below:
Invocations of foo(3) and bar(3) will result in:
int foo(int val)
{
int x = 0;
while (val > 0)
{
x = x + foo(val--);
}
return val;
}
int bar(int val)
{
int x = 0;
while (val > 0)
{
x = x + bar(val-1);
return val;
}
}
{
int x = 0;
while (val > 0)
{
x = x + foo(val--);
}
return val;
}
int bar(int val)
{
int x = 0;
while (val > 0)
{
x = x + bar(val-1);
return val;
}
}
Invocations of foo(3) and bar(3) will result in:
Explanation
Correct : C Programming
Similar Questions
What is the worst-case time complexity of insertion in an AVL tree?
Which operations on a binary search tree have O(h) complexity?
Compare search complexities of sorted array vs balanced BST.