February 2014
Beginner
1248 pages
62h 25m
English
Figure 18.6 shows how method fibonacci evaluates fibonacci(3). At the bottom of the figure we’re left with the values 1, 0 and 1—the results of evaluating the base cases. The first two return values (from left to right), 1 and 0, are returned as the values for the calls fibonacci(1) and fibonacci(0). The sum 1 plus 0 is returned as the value of fibonacci(2). This is added to the result (1) of the call to fibonacci(1), producing the value 2. This final value is then returned as the value of fibonacci(3).
Fig. 18.6 | Set of recursive calls for fibonacci(3).
Figure 18.6 raises some interesting issues about ...
Read now
Unlock full access