What is the complexity of this c function
Posted
by
Bunny Rabbit
on Stack Overflow
See other posts from Stack Overflow
or by Bunny Rabbit
Published on 2010-12-25T06:43:35Z
Indexed on
2010/12/25
7:54 UTC
Read the original article
Hit count: 157
what is the complexity of 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;
}
}
Please don't just post the complexity can you help me in understanding how to go about it .
EDIT: It was an objective question asked in an exam and the Options provided were 1.O(1) 2.O(n) 3.O(n!) 4.O(n^n)
© Stack Overflow or respective owner