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
It connects computers in different cities and different countries
svetoff [14.1K]

Answer:

I think VPN firewall devices can do that.

5 0
3 years ago
Read 2 more answers
Questic
N76 [4]

Answer:

Temporary Data

Explanation:

6 0
3 years ago
Your sister wants to purchase Microsoft Office 2013 for her new laptop. She doesn't want to pay for a subscription, and she want
Pavel [41]

I would buy Microsoft Office 2013 Home and Business Pc License. Its better to purchase the product in all rather than a subscription.

5 0
3 years ago
How do operating system work?
SIZIF [17.4K]

Answer:

The "operating system" manages software and hardware on the computer. Uploads files, has great memory and processes management.

7 0
3 years ago
Oliver is creating an image of a fruit basket. From the basket, he wants the red apples to stand out among the rest so they will
Volgvan
He   can increase   the   thickness   of the paint on the   apples.
Or he can  use glossier  finish on the   apples  to make them stand out...
3 0
4 years ago
Other questions:
  • A ____ document identifies the purpose of the program being developed, the application title, the procedures to be followed when
    11·1 answer
  • What does iSCSI stand for?
    5·2 answers
  • Olivia creates a personal budget. She enters her current savings account balance in cell D3. In cell A3, she calculates her inco
    8·1 answer
  • Ryan is working on a document with many secotions. For each section,he wantes to have the title bolded,underlined,an blue. Which
    9·2 answers
  • All mla text is double spaced. true false
    13·2 answers
  • Why was the IPv6 address format created? Select one:
    12·1 answer
  • Mobile computing is growing in importance each and every day, and the IT manager must take that into account. Do some web resear
    14·1 answer
  • Write an application named Hurricane that outputs a hurricane’s category based on the user’s input of the wind speed. Category 5
    7·1 answer
  • Please help me.
    8·2 answers
  • PLSS HELP ASAP ILL GIVE BRAINLIEST THANKS
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!