jeffgerickson / algorithms

Bug-tracking for Jeff's algorithms book, notes, etc.
7.92k stars 1.02k forks source link

Chapter 3, Section 3.1, Page 97: Pseudocode consistency for Fibonacci #64

Closed mousseinov closed 5 years ago

mousseinov commented 5 years ago

Not an error and more cosmetic but on page 96 the recurrence relation for the fibonacci sequence it is defined as F(n) = 0 when n = 0, F(n) = 1 when n = 1, and F(n) = F(n-1) + F(n-2) otherwise. On page 97 it shows the same algorithm written in pseudocode but for the case of n = 1 in the pseudocode it says to return n, which still works and isn't an error, but is slightly inconsistent with the recurrence and returning 1 instead would be more consistent.