{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

05-Recursion02 - Ch Chapter 3 Recursion This material is...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Ch t 3 R i Chapter 3: Recursion This material is based on contents the book: “Data structures, Algorithms, and Software Principles in C”, from T.A. Standish. Parts also under permission from David McCaughan, University of Guelph, Canada. USF – COP4530 – Data Structures Summer 2009 1 of 21
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Fibonacci numbers Is the following sequence of numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, … First two Fibonacci numbers: 0, 1. Each other number is the sum of the previous two How can the recursive function be defined? First, the mathematical definition eases thinking n if (n <= 1) Fibonacci(n) = Fibonacci (n-1) + Fibonacci(n-2) otherwise n USF – COP4530 – Data Structures Summer 2009 2 of 21
Image of page 2