1 / 33

# Good morning! - PowerPoint PPT Presentation

Good morning!. Recursive Algorithms. Example: Gift box!. Example: Gift box!. Example: Gift box!. Value of gift box : Equation?. Example: Treasure hunt!. What is recursion?. Popular in math definitions Inductive proof. Example: factorial(n). Example: factorial(n).

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Good morning!' - ide

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Good morning!

### Recursive Algorithms

• Popular in math definitions

• Inductive proof

• Non-recursive solution

• Stack memory

• How much stack memory is needed?

• Method invocations & returns diagram

• Example: factorial(5)

• Method invocations & returns diagram

• Example: fibonacci(n)

• Tree diagram

• Example: fibonacci(n)

fibonacci(n) : non-recursive solution?

• Recurrence relation & Time complexity

Example: Change for \$ 100

• Available denominations: 1c, 5c, 10c, 25c, \$1, \$2, \$5, \$10, \$20, \$50, \$100

• How many combinations are there?

• Parameters

• Tail recursion

• Recursion is one of the difficult concepts to understand, perhaps it is not that intuitive.

• As per a few mathematicians & CS folks, it is one of the most beautiful concepts!

• While it is not used much in commercial applications, it certainly puts your logical thinking skills to work!

• It is easy to remove tail recursion, but all others are lot harder to remove.