Order
-
Writing a program to compute n series of Fibonachi (Recursive and No Recursive ) I wrote this for non recursive
#include
using namespace std;int Fibo(int number);
int _tmain(int argc, _TCHAR* argv[])
{
int i,sum,n,a1,a2;
cout<<"enter number : "<>n;
i=3;
sum=0;
if(n==1)
cout<<"1";
else if(n==2)
cout<<"1,1";
else
{
cout<<"1 ,1 ,";
a1=1,a2=1;
while (i<=(n))
{
sum=a1+a2;
cout<>nn;
while(ii<=nn)
{
cout<<"\t"<
buw my question how can I compare these two methods for memory usage and their speed? -
Writing a program to compute n series of Fibonachi (Recursive and No Recursive ) I wrote this for non recursive
#include
using namespace std;int Fibo(int number);
int _tmain(int argc, _TCHAR* argv[])
{
int i,sum,n,a1,a2;
cout<<"enter number : "<>n;
i=3;
sum=0;
if(n==1)
cout<<"1";
else if(n==2)
cout<<"1,1";
else
{
cout<<"1 ,1 ,";
a1=1,a2=1;
while (i<=(n))
{
sum=a1+a2;
cout<>nn;
while(ii<=nn)
{
cout<<"\t"<
buw my question how can I compare these two methods for memory usage and their speed?messages wrote:
buw my question how can I compare these two methods for...their speed?
How about calling
time()
before and after?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Writing a program to compute n series of Fibonachi (Recursive and No Recursive ) I wrote this for non recursive
#include
using namespace std;int Fibo(int number);
int _tmain(int argc, _TCHAR* argv[])
{
int i,sum,n,a1,a2;
cout<<"enter number : "<>n;
i=3;
sum=0;
if(n==1)
cout<<"1";
else if(n==2)
cout<<"1,1";
else
{
cout<<"1 ,1 ,";
a1=1,a2=1;
while (i<=(n))
{
sum=a1+a2;
cout<>nn;
while(ii<=nn)
{
cout<<"\t"<
buw my question how can I compare these two methods for memory usage and their speed? -
messages wrote:
buw my question how can I compare these two methods for...their speed?
How about calling
time()
before and after?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
What you need is called a profiler. Here is a question on Stack Overflow[^] about free C/C++ profilers.
-
I have to compute it myself on the paper without any program. but I cant do it,could you help me please?
Then you are probably wanting to compute Big O notation, and you can find a really great answer here: http://stackoverflow.com/questions/3255/big-o-how-do-you-calculate-approximate-it[^] Big O notation was developed to give a machine independent view of the performance of a piece of code. Since "performance" depends greatly upon what you run it on (your code would be slow on a 386 but fast on a i7-4ghz), there needs to be a way to calculate relative performance. That is what Big O was designed for and it is a very difficult concept to grasp.
-
Writing a program to compute n series of Fibonachi (Recursive and No Recursive ) I wrote this for non recursive
#include
using namespace std;int Fibo(int number);
int _tmain(int argc, _TCHAR* argv[])
{
int i,sum,n,a1,a2;
cout<<"enter number : "<>n;
i=3;
sum=0;
if(n==1)
cout<<"1";
else if(n==2)
cout<<"1,1";
else
{
cout<<"1 ,1 ,";
a1=1,a2=1;
while (i<=(n))
{
sum=a1+a2;
cout<>nn;
while(ii<=nn)
{
cout<<"\t"<
buw my question how can I compare these two methods for memory usage and their speed?in first program you use more variable