1. Compute the Fibonacci sequence in three ways: (a) binary recursion(slow) (b) linear recursion (fast) (c) iterative(fast) Report how long it takes for each function when it computes the 50th Fibonacci num- ber. The first 50 Fibonacci numbers are: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 4807526976 7778742049 2. Implement binary search in both iterative and recursive ways. Test your implementa- tions using an array of size 10000.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question

Computer Science

1. Compute the Fibonacci sequence in three ways:
(a) binary recursion(slow)
(b) linear recursion (fast)
(c) iterative(fast)
Report how long it takes for each function when it computes the 50th Fibonacci num-
ber.
The first 50 Fibonacci numbers are:
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
610 987 1597 2584 4181 6765 10946 17711
28657 46368 75025 121393 196418 317811
514229 832040 1346269 2178309 3524578 5702887
9227465 14930352 24157817 39088169 63245986
102334155 165580141 267914296 433494437 701408733
1134903170 1836311903 2971215073 4807526976 7778742049
2. Implement binary search in both iterative and recursive ways. Test your implementa-
tions using an array of size 10000.
Transcribed Image Text:1. Compute the Fibonacci sequence in three ways: (a) binary recursion(slow) (b) linear recursion (fast) (c) iterative(fast) Report how long it takes for each function when it computes the 50th Fibonacci num- ber. The first 50 Fibonacci numbers are: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 4807526976 7778742049 2. Implement binary search in both iterative and recursive ways. Test your implementa- tions using an array of size 10000.
Expert Solution
steps

Step by step

Solved in 9 steps with 4 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning