Answer:
umm... I hate to break it to you but this is something you're gonna have to do on your own since the likelihood of someone being in your exact class is very low I mean people could write some random stuff in here but if it doesn't match up with what you learned in class then does it really even matter at that point? your teacher will know you cheated and will probably make you do it from scratch and will check thoroughly to make sure it's your work (if you're in highschool and/or the teacher is nice enough to give you a second chance) or just fail you completely (if you're in college and/or just have a really mean teacher who doesn't give second chances). so I recommend taking the time to do this yourself and not risking the consequences.
Explanation:
Answer:
The value of k is 4
Explanation:
Solution
Given that:
k = integer
Input size = 500
The algorithm takes a run of = 16 seconds
Input size = 750
The algorithm takes a run of = 81 seconds
Now,
We have to determine the value of k
The equation is shown below:
(500)^k /16 = (750) ^k /81
Thus
(750/500)^ k = 81/16
= (3/2)^k
=(3/2)^ 4
k is = 4
Literally just do a colon and parenthesis :(
:( :-(
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;
}