previous | start | next

## The Efficiency of Recursion

- The output from the function indicates why the computation takes so long.

  >     Entering fib: n = 6
  >     Entering fib: n = 5
  >     Entering fib: n = 4
  >     Entering fib: n = 3
  >     Entering fib: n = 2
  >     Exiting fib: n = 2 return value = 1
  >     Entering fib: n = 1
  >     Exiting fib: n = 1 return value = 1
  >     Exiting fib: n = 3 return value = 2
  >     Entering fib: n = 2
  >     Exiting fib: n = 2 return value = 1
  >     Exiting fib: n = 4 return value = 3
  >     Entering fib: n = 3
  >     Entering fib: n = 2
  >     Exiting fib: n = 2 return value = 1
  >     Entering fib: n = 1
  >     Exiting fib: n = 1 return value = 1
  >     Exiting fib: n = 3 return value = 2
  >     Exiting fib: n = 5 return value = 5
  >     Entering fib: n = 4
  >     Entering fib: n = 3
  >     Entering fib: n = 2
  >     Exiting fib: n = 2 return value = 1
  >     Entering fib: n = 1
  >     Exiting fib: n = 1 return value = 1
  >     Exiting fib: n = 3 return value = 2
  >     Entering fib: n = 2
  >     Exiting fib: n = 2 return value = 1
  >     Exiting fib: n = 4 return value = 3
  >     Exiting fib: n = 6 return value = 8

previous | start | next