C Complexity analysis Represent the time complexity of the f
C++ Complexity analysis: Represent the time complexity of the following recursive algorithm, T(n), as a recurrence equation:
int pow_7( int n ){
if ( n==1)
return 7;
if ( n > 1)
return ( 7 * pow_7( n-1 ) );
}
Solution
T(n) = T(n-1) + 1
T(n) = T(n-2)+2
suppose after k iteration
T(n) = T(n-k)+k
then T(n) = T(n-k-1)+k+1....T(n) = T(n-(k+1))+(k+1)
=> true for k+1 also.
T(n) = O(n)
