Solved

A Method Is Coded as Follows

Question 15

Essay

A method is coded as follows:
public static int foo( int n )
{
if ( n <= 0 )
return 0;
else
return ( foo( n - 1 ) + foo( n - 1 ) );
}
What is the running time of this method? Show your work.

Correct Answer:

verifed

Verified

O( 2n )
T(0) = 1
T(n) = T(n − 1) + T(n − ...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions