1 / 33

Introduction: Fibonacci Numbers

Introduction: Fibonacci Numbers. http://iti.wtf Algorithms and Data Structures. Artem A. Golubnichiy artem@golubnichij.ru Department of Software of Computer Facilities and Automated Systems Katanov Khakass State University. STRUCTURE OF THE CLASS. Problem Overview; Naive Algorithm;

mulhern
Download Presentation

Introduction: Fibonacci Numbers

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction:Fibonacci Numbers http://iti.wtf Algorithms and Data Structures Artem A. Golubnichiy artem@golubnichij.ru Department of Software of Computer Facilities and Automated Systems KatanovKhakass State University

  2. STRUCTURE OF THE CLASS • Problem Overview; • Naive Algorithm; • Efficient Algorithm.

  3. DEFINITION In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

  4. DEFINITION In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones.

  5. DEFINITION In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597 . . .

  6. DEVELOPED TO STUDY RABBIT POPULATIONS

  7. RAPID GROWTH

  8. RAPID GROWTH

  9. RAPID GROWTH

  10. RAPID GROWTH

  11. RAPID GROWTH

  12. FORMULA

  13. FORMULA

  14. EXAMPLE F20 = 6765

  15. EXAMPLE F20 = 6765 F50 = 12586269025

  16. EXAMPLE F20 = 6765 F50 = 12586269025 F100 = 354224848179261915075

  17. EXAMPLE F20 = 6765 F50 = 12586269025 F100 = 354224848179261915075 F500 = 13942322456169788013972438287040728395007025658769730 7264108962948325571622863290691557658876222521294125

  18. COMPUTING FIBONACCI NUMBERS

  19. ALGORITHM

  20. RUNNING TIME Let T(n) denote the number of lines of code executed by FibRecurs(n) if n ≤ 1 T(n) = 2

  21. RUNNING TIME Let T(n) denote the number of lines of code executed by FibRecurs(n) if n ≥ 2 T(n) = 3 + T(n – 1) + T(n – 2)

  22. RUNNING TIME Therefore T(n) ≥ Fn T(100) ≈ 1.77∙1021 Takes 56000 years at 1Ghz

  23. WHY SO SLOW? Fn Fn-2 Fn-1 Fn-2 Fn-3 Fn-3 Fn-4 Fn-4 Fn-5 Fn-5 Fn-6 Fn-4 Fn-4 Fn-3 Fn-5

  24. WHY SO SLOW? Fn Fn-2 Fn-1 Fn-2 Fn-3 Fn-3 Fn-4 Fn-4 Fn-5 Fn-5 Fn-6 Fn-4 Fn-4 Fn-3 Fn-5

  25. WHY SO SLOW? Fn Fn-2 Fn-1 Fn-2 Fn-3 Fn-3 Fn-4 Fn-4 Fn-5 Fn-5 Fn-6 Fn-4 Fn-4 Fn-3 Fn-5

  26. ANOTHER ALGORITHM Imitate hand computation: 0, 1

  27. ANOTHER ALGORITHM Imitate hand computation: 0, 1, 1 0 + 1 = 1

  28. ANOTHER ALGORITHM Imitate hand computation: 0, 1, 1, 2 0 + 1 = 1 1 + 1 = 2

  29. ANOTHER ALGORITHM Imitate hand computation: 0, 1, 1, 2, 3 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3

  30. ANOTHER ALGORITHM Imitate hand computation: 0, 1, 1, 2, 3, 5 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5

  31. ANOTHER ALGORITHM Imitate hand computation: 0, 1, 1, 2, 3, 5, 8 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5 3 + 5 = 8

  32. NEW ALGORITHM T(n) = 2n + 2. So T(100) = 202

  33. VISUALIZING ALGORITHMS Recursive Table

More Related