c) Recursive computation with dynamic programming.

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

c++ Language

I need help with question #6 part c please.

I asked this question 3 times but i keep getting programs im not able to run. Things with "DP" etc... Please make it as simple as possible for me thank you so so much. 
I did a and b already, i just need with c using dynamic programming. Please and thanks!

6) There are other recursive functions such as the Lucas Sequence, how can you apply what you have
learned to it?
a) Iteratively computation
b) Recursive computation
c) Recursive computation with dynamic programming.
a)
int lucas (int num)
int a = 2, b = 1, Saį;
if (num ==0)
return a;
for (i =2; i <=num; i++)
{
= atki
a = b;
C
b = c;
}
return b;
b)
int Lucassequence ( int num) {
if (num == 0)
return 2;
if (num == 1)
return 1;
return Lugasfeauence (num
- 1)
+ Lucasseguence (num - 2);
С.
Transcribed Image Text:6) There are other recursive functions such as the Lucas Sequence, how can you apply what you have learned to it? a) Iteratively computation b) Recursive computation c) Recursive computation with dynamic programming. a) int lucas (int num) int a = 2, b = 1, Saį; if (num ==0) return a; for (i =2; i <=num; i++) { = atki a = b; C b = c; } return b; b) int Lucassequence ( int num) { if (num == 0) return 2; if (num == 1) return 1; return Lugasfeauence (num - 1) + Lucasseguence (num - 2); С.
Study the Fibonacci number sequence in the following forms: (1) iterative (sequential), (2) recursive, (3)
and closed form solution.
1) Examine the theoretical measure of time complexity of each.
a) Using theory compare the number of operations and time taken to compute Fibonacci numbers
recursively versus that needed to compute them iteratively.
b) How many prime Fibonacci numbers are there, and how many can you find?
c) Find the smallest Fibonacci number > 1,000,000
d) Find the smallest Fibonacci number > 1,000,000,000
2) Implement each Fibonacci form (1, 2, and 3 see above) in the C++ language (C++ 17).
Write four functions:
a) An iterative function that accepts a non-negative integer n and returns the nth Fibonacci number.
b) A recursive function that inputs a non-negative integer n and returns the nth Fibonacci number.
c) An improved recursive function that employs dynamic programming to improve the efficiency.
d) The closed form of the Fibonacci sequence (be sure to reference the golden ratio)
3) Using your software, compute a set of Fibonacci numbers employing the four techniques (c.f. 2, above);
for example, use n: {10, 15, 40, 41, 42, 50, 60, 100, 500, 600}.
a) Measure the time for each computation-send the results to a file.
* Recommend using the Chrono library from C++
b) Make certain you have "sufficient" data for convincing results.
4) Import your data (from 3) to excel for easy graphing
5) Compare the theoretical curves of Big-O with the empirical results.
a) Try running on machines with [significantly] different speeds.
b) Compare methods to answer the find an answer to question 1.c, above.
6) There are other recursive functions such as the Lucas Sequence, how can you apply what you have
learned to it?
a) Iteratively computation
b) Recursive computation
c) Recursive computation with dynamic programming.
Transcribed Image Text:Study the Fibonacci number sequence in the following forms: (1) iterative (sequential), (2) recursive, (3) and closed form solution. 1) Examine the theoretical measure of time complexity of each. a) Using theory compare the number of operations and time taken to compute Fibonacci numbers recursively versus that needed to compute them iteratively. b) How many prime Fibonacci numbers are there, and how many can you find? c) Find the smallest Fibonacci number > 1,000,000 d) Find the smallest Fibonacci number > 1,000,000,000 2) Implement each Fibonacci form (1, 2, and 3 see above) in the C++ language (C++ 17). Write four functions: a) An iterative function that accepts a non-negative integer n and returns the nth Fibonacci number. b) A recursive function that inputs a non-negative integer n and returns the nth Fibonacci number. c) An improved recursive function that employs dynamic programming to improve the efficiency. d) The closed form of the Fibonacci sequence (be sure to reference the golden ratio) 3) Using your software, compute a set of Fibonacci numbers employing the four techniques (c.f. 2, above); for example, use n: {10, 15, 40, 41, 42, 50, 60, 100, 500, 600}. a) Measure the time for each computation-send the results to a file. * Recommend using the Chrono library from C++ b) Make certain you have "sufficient" data for convincing results. 4) Import your data (from 3) to excel for easy graphing 5) Compare the theoretical curves of Big-O with the empirical results. a) Try running on machines with [significantly] different speeds. b) Compare methods to answer the find an answer to question 1.c, above. 6) There are other recursive functions such as the Lucas Sequence, how can you apply what you have learned to it? a) Iteratively computation b) Recursive computation c) Recursive computation with dynamic programming.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 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