How can I calculate the time complexity of a recursive algorithm?
int pow1(int x,int n) { if(n==0){ return 1; } else{ return x *
So I'm guessing you're raising x to the power n. pow1 takes O(n).
You never change the value of x but you take 1 from n each time until it gets to 1 (and you then just return) This means that you will make a recursive call n times.