Question

Your C++ project relate to the dynamic programming to solve the calculating Fibonacci numbers should demonstrate:...

Your C++ project relate to the dynamic programming to solve the calculating Fibonacci numbers should demonstrate:

  • Header files
  • Abstract Class
  • Subclasses
  • Virtual function (in addition to the pure virtual function)
  • Inheritance
  • Polymorphism
  • Pointers
  • Static variables
  • Static functions
  • Exceptions
  • Templates
  • File I/O
  • Overloaded << or >> operator
  • Overloaded operators (at least one additional)

Extra points for:

  • Recursion
  • Linked lists / Stacks / Queues
  • Binary search trees
  • Binary File with random access
  • A friend function not related to the << and >> operator

Don’t forget: analysis, design, testing, pseudocode & documentation!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Following is the code and design of the above problem using recursion,:

#include<iostream>
using namespace std;
void Fib(int l){
static int num1=0, num2=1, num3;
if(l>0){
num3 = num1 + num2;
num1 = num2;
num2 = num3;
cout<<num3<<" ";
Fib(l-1);
}
}
int main(){
int n;
cout<<"Enter the length of your Fibonacci series: ";
cin>>n;
cout<<"Fibonacci Series: ";
cout<<"0 "<<"1 ";
Fib(n-2); //n-2 because 2 numbers are already printed
return 0;
}

Please find the attached screenshot of the output after testing:

After analysis the time complexity of this program is O(n) and space complexity is constant.

Add a comment
Know the answer?
Add Answer to:
Your C++ project relate to the dynamic programming to solve the calculating Fibonacci numbers should demonstrate:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT