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
Convert each of the fo" wing base ten representations to its equivalent binary form a. 6 b. 13 C. d. 18 e. 27
asambeis [7]

Answer:

6=110

13=1101

18=10010

27=11011

Explanation:

A decimal number is converted to binary number by constantly dividing the decimal number by 2 till the number becomes zero and then write the remainders in reverse order of obtaining them.Then we will get our binary number.

I will provide you 1 example:-

18/2 = 9   the  remainder =0

9/2 = 4    the remainder =1

4/2 = 2    the remainder =0

2/2 = 1     the remainder =0

1/2 = 0     the remainder =1

Writing the remainder in reverse order 10010 hence it is the binary equivalent of 18.

6 0
2 years ago
Given variables first and last, each of which is associated with a str, representing a first and a last name, respectively. Writ
valentina_108 [34]

Answer:

The python code is attached

Explanation:

  1. I defined a function called Fullname
  2. The function accepts 2 parameters first and last
  3. last[0] gives the first letter of the last variable
  4. last[0].upper() modifies the first letter as upper letter
  5. same applied to variable first
  6. + sign concatenates strings and variables to the variable name
  7. the function returns the variable name

5 0
3 years ago
Annie is a nutritionist. She is conducting seminars about following a healthy diet in various offices. Annie adds a picture of f
Novosadov [1.4K]

I believe in this case you would be using Clip Art.

Smart Art is used on words to make graphics usually.

Graphs are not pictures

Shapes are completely different


8 0
2 years ago
Read 2 more answers
Stacy is in the process of creating a storyboard for her personal website, but she is unable to decide which storyboarding techn
Shalnov [3]

Answer:

Webbed storyboard technique

Explanation:

There are several storyboard techniques; however, the best for a website is the webbed storyboard technique.

Coined from the word "web", this technique does not only help in linking pages within the website where a page can be access from other pages, it also links pages of the website to external pages.

An illustration is as follows:

From the homepage of a website, one can access the contact page, the about page, etc.

Each of the listed pages also have link back to the homepage and to every other pages.

5 0
2 years ago
Does technology make us more alone?
Anika [276]
Both yeah and no, depending on personal opinion
3 0
3 years ago
Other questions:
  • What are the 6 external parts of a computer
    14·1 answer
  • To open the dialog box for modifying styles, which step must you first complete in the Navigation pane?
    11·2 answers
  • What is the most common concern with using variable frequency drives?
    6·1 answer
  • Que es un programa de ordenador?
    10·1 answer
  • You are given the task of reading in n numbers and then printing them out in sorted order. Suppose you have access to a balanced
    12·1 answer
  • In chapter 11, we finally learn how the book got its title. What is the sign of the beaver? Is that what you expected when you r
    13·1 answer
  • Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the for
    10·1 answer
  • What can you use on Code.org's Web Lab to find and fix problems when you are writing code for your website?
    13·1 answer
  • What is the function for displaying differences between two or more scenarios side by side?
    11·2 answers
  • Please answer this simple (hard) question for me lol
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!