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
Which of the following types of access controls do not describe a lock? (a)- Directive (b)- Physical (c)- Preventative (d)- Dete
Mrac [35]

Answer:

Directive

Explanation:

A directive access control is used to direct, confine, or control the actions of subject to force compliance with security policies. Some examples of direct access controls are: security guards, guard dogs, posted notifications, monitoring, supervising, work task procedures, and awareness training. It can also be categorized by how it is implemented; for example, it can be administrative, logical/technical, or physical.

7 0
3 years ago
Combination lock uses three numbers beween 1 and 36 with repetition , how mant combinations are possiable
artcher [175]
There are 46656 possible combinations.

6 0
3 years ago
A common attack in which a client's cookies, security tokens, or other personal information is obtained and used to impersonate
o-na [289]

Answer:

Identity Theft. i hope this helps :D

5 0
2 years ago
Which Windows installation method requires that you manually rename computers after the installation?​
levacccp [35]

Answer:

Command line

Explanation:

  • After installation of the machine one needs to manually rename the computer. This can be done through the start then settings, then system, and select rename the PC in the right-hand side column.
3 0
2 years ago
Part B: Find the value of G: if A = 3, b=4, and C = 5.
antiseptic1488 [7]

Answer:

G=(A^3 + B) * 4-c^2

To calculate G if A=3, b=4 and C=5

cobegin

p1: A^3 = 27

P2:C^2 =25

P3: p1 +B =31

P4:P3*4 =124

P5:P4-P2 =99

coend

Explanation:

One operation is performed at a time, and on the basis of priority as we have only one processor.

6 0
3 years ago
Other questions:
  • In programming, what is a floating-point number?<br>​
    7·1 answer
  • Can i earn money at weegy.com ?
    10·1 answer
  • The_provides access to the internet may also be internal​
    9·1 answer
  • Of which of the following devices are point, drag, and click actions?
    15·1 answer
  • Implement a java program to find the smallest distance between two neighbouring numbers in an array.
    7·1 answer
  • Differentiate between the broadcasting and telecommunication
    5·1 answer
  • Consider the following threats to Web security, and describe how each is countered by a particular feature of SSL.
    15·1 answer
  • List the gcc command-line options for each of the following: Generate a .o file rather than an executable. Generate a .s (assemb
    6·1 answer
  • Why is 0.3333333333333333 the output of print(1/6 + 1/6) in python?
    8·1 answer
  • In your opinion, who is the best Mine.Craft player overall?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!