
Recursion is explained in
Chapter 13.
REFERENCE POINT
15.3 Running Time Analysis of Algorithms and Impact of Coding: Evaluating Recursive Methods 1129
15.3 Running Time Analysis of Algorithms and Impact of Coding:
Evaluating Recursive Methods
In this section, we will learn how to compute the running time of a recur-
sive method. We will also look at how coding a method has a direct impact
on its running time.
Consider coding a recursive method that takes one parameter, n, and
returns 2
n
. There are several ways to code that method, and we will consider
two of them here so that we can assess which algorithm is more efficient.
Our first method, powerOf2A ...