lecture10 - CS 473: Algorithms Chandra Chekuri...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 473: Algorithms Chandra Chekuri [email protected] 3228 Siebel Center University of Illinois, Urbana-Champaign Fall 2009 Chekuri CS473ug Fibonacci Numbers Part I Introduction to Dynamic Programming Chekuri CS473ug Fibonacci Numbers Recursion Reduction: reduce one problem to another Recursion: a special case of reduction reduce problem to a smaller instance of itself self-reduction Chekuri CS473ug Fibonacci Numbers Recursion Reduction: reduce one problem to another Recursion: a special case of reduction reduce problem to a smaller instance of itself self-reduction Problem instance of size n is reduced to one or more instances of size n- 1 or less. For termination, problem instances of small size are solved by some other method as base cases Chekuri CS473ug Fibonacci Numbers Recursion in Algorithm Design Tail Recursion: problem reduced to a single recursive call after some work. Easy to convert algorithm into iterative or greedy algorithms. Examples: Interval scheduling, MST algorithms, etc. Divide and Conquer: problem reduced to multiple independent sub-problems that are solved separately. Conquer step puts together solution for bigger problem. Dynamic Programming: problem reduced to multiple (typically) dependent or overlapping sub-problems. Use memoization to avoid recomputation of common solutions leading to iterative bottom-up algorithm. Chekuri CS473ug Fibonacci Numbers Fibonacci Numbers Fibonacci numbers defined by recurrence: F ( n ) = F ( n- 1) + F ( n- 2) and F (0) = 0 , F (1) = 1 . These numbers have many interesting and amazing properties. A journal The Fibonacci Quarterly ! F ( n ) = ( φ n- (1- φ ) n ) / √ 5 where φ is the golden ratio (1 + √ 5) / 2 ’ 1 . 618. lim n →∞ F ( n + 1) / F ( n ) = φ Chekuri CS473ug Fibonacci Numbers Fibonacci Numbers Fibonacci numbers defined by recurrence: F ( n ) = F ( n- 1) + F ( n- 2) and F (0) = 0 , F (1) = 1 . These numbers have many interesting and amazing properties. A journal The Fibonacci Quarterly ! F ( n ) = ( φ n- (1- φ ) n ) / √ 5 where φ is the golden ratio (1 + √ 5) / 2 ’ 1 . 618. lim n →∞ F ( n + 1) / F ( n ) = φ Question: Given n , compute F ( n ). Chekuri CS473ug Fibonacci Numbers Recursive Algorithm for Fibonacci Numbers Fib(n): if (n = 0) return 0 else if (n = 1) return 1 else return Fib(n-1) + Fib(n-2) Chekuri CS473ug Fibonacci Numbers Recursive Algorithm for Fibonacci Numbers Fib(n): if (n = 0) return 0 else if (n = 1) return 1 else return Fib(n-1) + Fib(n-2) Running time? Let T ( n ) be the number of additions in Fib(n). Chekuri CS473ug Fibonacci Numbers Recursive Algorithm for Fibonacci Numbers Fib(n): if (n = 0) return 0 else if (n = 1) return 1 else return Fib(n-1) + Fib(n-2) Running time? Let T ( n ) be the number of additions in Fib(n)....
View Full Document

This note was uploaded on 01/22/2012 for the course CS 573 taught by Professor Chekuri,c during the Fall '08 term at University of Illinois, Urbana Champaign.

Page1 / 122

lecture10 - CS 473: Algorithms Chandra Chekuri...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online