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
What is 1gb in bits?​
Irina-Kira [14]

Answer:

8e+9

Explanation:

3 0
3 years ago
Read 2 more answers
HELP ME PLEASE!!!!!!!!!!!!
Mila [183]

Answer:

b b isss the right answer

5 0
3 years ago
Read 2 more answers
An independent frame that holds a program, document, or folder contents in windows 7 is called a ____.
svetlana [45]
Window.

Have a wonderful day!~
7 0
3 years ago
The process of determining that a user has permission to perform a particular action on a computer is called
Doss [256]
I believe that would be authorization.
5 0
3 years ago
While the economy of eastern Washington relies on farming, western Washington relies on technology.
Strike441 [17]
True- western Washington hosts modern technologies supporting both academic and co curricular activities
3 0
3 years ago
Read 2 more answers
Other questions:
  • When was Microsoft released to public schools?
    10·1 answer
  • Which binary number is equivalent to the decimal number 104?
    9·1 answer
  • how much should an organization consider moving into the cloud before full outsourcing starts making more business sense
    14·2 answers
  • A(n) ____________________ or cryptosystem is an encryption method or process encompassing the algorithm, key(s) or cryptovariabl
    11·1 answer
  • Write a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in
    5·1 answer
  • jeff wants to create a website with interactive and dynamic content. Which programming language will he use?
    11·2 answers
  • What is the big-O performance estimate of the following function?
    15·2 answers
  • When a collection of honeypots connects several honeypot systems on a subnet, it may be called a(n) honeynet
    9·1 answer
  • Es la actividad que posibilita comunicar gráficamente ideas, hechos y valores procesados y sintetizados en términos de forma y c
    11·1 answer
  • Help me please, I'm attempting a test<br>​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!