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]
2 years ago
12

Compare Fibonacci (recursion vs. bottom up)

Computers and Technology
1 answer:
ipn [44]2 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
Discuss the main characteristics of the database approach and how it differs from traditional file systems.
Firdavs [7]

The database system allows the creation of a single depository of information, which is updated periodically and which can be used simultaneously by many users, since this type of system allows the effective sharing of all data stored in its depository . In addition, this is a secure system and is very difficult to break into. This is because of the efficiency of the software used to maintain it. However, the use of these softwares can be a little complicated for users, in addition to requiring a high economic cost to obtain them.

The traditional file system, in turn, each user must obtain their own file related to the application they want to run. This may seem dull in comparison to the database, but it is advantageous as it does not require any spending on software, as it is simple and there are several cheap and efficient tools and editors on the market. However, this system is not so safe, it can cause isolation of data and even data inconsistency, which disrupts the entire system.

6 0
3 years ago
A built-in tool that enables you to use text to type in commands for the operating system is called the _____ prompt.
Natalija [7]
Command prompt is the answer and on Apple devices it is called Terminal.
8 0
3 years ago
Read 2 more answers
Which word or phrase refers to an increasingly common method of computing and storing files?
Alecsey [184]
The answer is Cloud computing
Hope this helps-
3 0
3 years ago
Read 2 more answers
Karel coding 2.1.4 superkarel cleanup
kherson [118]

Answer:

hi, try using Code Plans

Explanation:

it is a free website that include videos and articles on this stuff

6 0
2 years ago
Read 2 more answers
The U.S. continues to become more dependent on the global domain within the information environment consisting of the interdepen
Hoochie [10]

Answer:

"Cyberspace " is the right answer.

Explanation:

  • Cyberspace seems to be an interactive computational environment, unconstrained by distance and perhaps other functional disabilities. William Gibson developed the word for representing a sophisticated augmented reality infrastructure in his story Neuromancer.
  • The virtual space generated over the network through synchronized computing devices.

So that the above would be the correct answer.

4 0
3 years ago
Other questions:
  • What type of data visual would you use to illustrate trends over time? Gantt chart Bar graph Line chart Scatter diagrams
    5·1 answer
  • In this problem we consider sending real-time voice from Host A to Host B over a packet-switched network (VoIP). Host A converts
    12·1 answer
  • 11. John wants to share resources and move a large volume of data quickly over the Internet. John should use which of the follow
    14·1 answer
  • The first time you save a document, which screen appears
    8·2 answers
  • THE bestValue PROBLEM Using the Camera structure defined in file p1.cpp, write the function named bestValue(). The function take
    13·1 answer
  • Which type of password would be considered secure
    5·2 answers
  • If you are going to refer to a few dozen classes in your application, how do<br> you do it?
    6·1 answer
  • Which Excel function or tool will you use to display the cells that are referred to by a formula in the selected cell
    8·1 answer
  • Why would researching the average earnings by major and by career be useful to you as you choose an institute for higher educati
    10·1 answer
  • The RGB value below produces a shade of purple. What does the number 175
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!