Consider the following C-function: double foo (int n){ int i; double sum; if…
GATE · 2005 · CS
Consider the following C-function:
double foo (int n){
int i;
double sum;
if (n == 0) return 1.0;
else{
sum = 0.0;
for (i = 0; i < n; i++)
sum += foo (i);
return sum;
}
}
The space complexity of the above function is:
- A.
O(1)
- B.
O(n)
- C.
O(n!)
- D.
O(nn)
Attempted by 314 students.
Sign up free to check your answer
Sign up freeLoading lesson…