General Plan For Analyzing Efficiency of Recursive Algorithms
General Plan For Analyzing Efficiency of Recursive Algorithms
algorithms:
1. Decide on parameter n indicating input size
3. Check whether the number of times the basic operation is executed depends only on the
input size n. If it also depends on the type of input, investigate worst, average, and best
case efficiency separately.
4. Set up recurrence relation, with an appropriate initial condition, for the number of times
the algorithm’s basic operation is executed.
//Computes n! recursively
if n = = 0
return 1
else
return Factorial (n – 1) * n
Analysis:
1. Input size: given number = n