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
Can we declare top level classes as private or protected?
uysha [10]

Answer and Explanation:

top level class can not be declare as private or protected. It is always public. If we declare a top level class as private then the compiler always complain that the  private is not allowed  and if we declare top level class as protected then compiler complain that modifier protection is not allowed here. so we can not declare top level class as private or protected

5 0
4 years ago
List at least three things that are included as part of property rights.
KatRina [158]
1) exclusivity of rights to choose the use of the resource

2) exclusivity of rights to the severices of a resource

3) rights to exchange at mutually agreeable terms
4 0
3 years ago
Choose the term that best completes each sentence.
olga2289 [7]

Answer:

The answer to the above questions is given in explanation section:

Explanation:

abstraction hides the details about a specific piece of information.

The suitable match for this is Data

Because the word "Piece of information " can only be referred to data not to process.

Now look at the second

abstraction hides the details about a specific process

The suitable match here is procedural.

because specific process can only be referred to procedure not to data.

6 0
3 years ago
Read 2 more answers
Why are hardline Ethernet connections always faster than WiFi?
Bumek [7]
Because Ethernet uses cables, it tends to work slightly faster than a wireless connection. Wireless connections are a bit slower, but provide the convenience of using it within range. Today, WiFi hotspots can easily be found in many places. Thus, the choice lies between speed and convenience.
Wi-Fi vs. Ethernet: Which Connection to Use?
by Allen Jame
3 0
3 years ago
If you attempt an edgeunity quiz is your latest attempt the one counted?
tekilochka [14]

Answer:

Hello

Explanation:

Hello profile picture of a nub how are you doing today?

8 0
3 years ago
Other questions:
  • âwhat two log files are used by older versions of unix and newer version of linux to store log information
    10·2 answers
  • After the data are appropriately processed, transformed, and stored, what is a good starting point for data mining?
    15·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    13·1 answer
  • Which is NOT a benefit of using visual aids?
    9·2 answers
  • Which term collectively describes hard disks, CDs, and flash drives?
    11·2 answers
  • Imagine you are responsible for making a presentation that includes a representation of the logic flow through a process. You un
    11·1 answer
  • What determines WiFi speeds, please list all your answers and explain how it affects the WiFi speed.
    8·1 answer
  • Which tools do you use for LinkedIn automation?
    14·1 answer
  • Simple example of hybrid computer​
    7·2 answers
  • After a group sets a project schedule, members should be prepared to
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!