next up previous
Next: Example: traversal of a Up: Unit 11 Previous: Example: Towers of Hanoi

Number of activations in the case of multiple recursion

When we make use of multiple recursion, we have to consider that the number of recursive activations could become exponential in the depth of the recursive calls (i.e., in the maximum height of the stack of ARs).

Example: Towers of Hanoi

act(n)
= number of activations of moveADisk() for n disks
= number of moves of a disk

act(n) = $\displaystyle \cases{
1, & if \(n=1\)\cr
1 + 2 \cdot \mathit{act}(n-1), & if \(n>1\)}
$

Even if we ignore ``1 +'' in the case for n > 1, we have that act(n) = 2n-1. Hence we have that act(n) > 2n-1.

Note that, in the case of the problem of the Towers of Hanoi, the exponential number of activations (i.e., moves) is an intrinsic characteristic of the problem, i.e., there is no better solution.


next up previous
Next: Example: traversal of a Up: Unit 11 Previous: Example: Towers of Hanoi