1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sedaia [141]
3 years ago
12

Compare Fibonacci (recursion vs. bottom up)

Computers and Technology
1 answer:
ipn [44]3 years ago
7 0

Answer:

C++ code explained below

Explanation:

#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int FiboNR(int n)

{

int max=n+1;

int F[max];

F[0]=0;F[1]=1;

for(int i=2;i<=n;i++)

{

F[i]=F[i-1]+F[i-2];

}

return (F[n]);

}

int FiboR(int n)

{

if(n==0||n==1)

return n;

else

return (FiboR(n-1)+FiboR(n-2));

}

int main()

{

long long int i,f;

double t1,t2;

int n[]={1,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75};

cout<<"Fibonacci time analysis ( recursive vs. non-recursive "<<endl;

cout<<"Integer FiboR(seconds) FiboNR(seconds) Fibo-value"<<endl;

for(i=0;i<16;i++)

{

clock_t begin = clock();

f=FiboR(n[i]);

clock_t end = clock();

t1=double(end-begin); // elapsed time in milli secons

begin = clock();

f=FiboNR(n[i]);

end = clock();

t2=double(end-begin);

cout<<n[i]<<" "<<t1*1.0/CLOCKS_PER_SEC <<" "<<t2*1.0/CLOCKS_PER_SEC <<" "<<f<<endl; //elapsed time in seconds

}

return 0;

}

You might be interested in
Idea citizen activation
Tatiana [17]
<h2>Answer:</h2><h2>Idea citizen activation badge is a part of the idea silver award and is in the citizen category,helping you learn digital awareness,safety and ethics.</h2>

7 0
4 years ago
Read 2 more answers
The non-conditional boolean logical and operator is written as ____.
bixtya [17]
False because whhy would it be true. words of logic

3 0
3 years ago
Match each definition with the term it describes. A(n) ______ provides identification and addressing information for computers a
earnstyle [38]

Answer:

IP address, LAN, WAN

Explanation:

6 0
3 years ago
What is the error in the following line: (1)<br><br> age=int(input("Enter your age:")
Ainat [17]

Answer:

14

Explanation:

6 0
3 years ago
In which view are fields set up in MS Access?
Phantasy [73]

Answer:On the Home tab, in the Views group, click View, and then click Design View. In the table design grid, select the field or fields that you want to use as the primary key. To select one field, click the row selector for the field that you want.

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • A receiver requires 10nW as input power. If all the system losses add up to 50dB, then how much power is required from the sourc
    15·1 answer
  • A ____ is a copy that is kept in case values need to be restored to their original state.
    5·1 answer
  • A honeypot is sometimes called a(n) __________.
    11·1 answer
  • You are an administrator for a large corporation and you are responsible for deploying computers often and quickly. Which server
    5·1 answer
  • If you are trying to improve your budget and spending, which option would save you the most money?
    13·2 answers
  • _______is a network of physical objects embedded with sensors, processors, software and network connectivity capability to enabl
    6·1 answer
  • You have been hired as a Systems Analyst in a famous Burger chain. Due to its popularity, the demands from customers also increa
    7·1 answer
  • What is the location in the base interface of the link to
    7·1 answer
  • Describe how computer are used in ticket counter?​
    10·1 answer
  • _____ have networked and texted all of their lives with smartphones, tablets, and high-speed Internet.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!