Hi all,

Can anybody tell me how to calculate the order of a recursive function.

Lets take factorial function.

Without using recursion

int x =1;

for(int i = 1;i<=n;i++)

x = x*i;

In this case the order will the O(n) in terms of time and in terms of space it will be O(1).

Assuming I am right. Correct me otherwise.

Now suppose I implemet the same factorial with rtecursion

return(n==0? 1 : n * fact(n-1));

What will be the order in time and space????