Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Order

Order

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformance
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    messages
    wrote on last edited by
    #1

    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?

    D R R 3 Replies Last reply
    0
    • M messages

      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?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • M messages

        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?

        R Offline
        R Offline
        Ron Beyer
        wrote on last edited by
        #3

        What you need is called a profiler. Here is a question on Stack Overflow[^] about free C/C++ profilers.

        M 1 Reply Last reply
        0
        • D David Crow

          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

          M Offline
          M Offline
          messages
          wrote on last edited by
          #4

          No its not a programming project.its about data structure lesson an I have to compute it myself.

          1 Reply Last reply
          0
          • R Ron Beyer

            What you need is called a profiler. Here is a question on Stack Overflow[^] about free C/C++ profilers.

            M Offline
            M Offline
            messages
            wrote on last edited by
            #5

            I have to compute it myself on the paper without any program. but I cant do it,could you help me please?

            R 1 Reply Last reply
            0
            • M messages

              I have to compute it myself on the paper without any program. but I cant do it,could you help me please?

              R Offline
              R Offline
              Ron Beyer
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • M messages

                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?

                R Offline
                R Offline
                rashin ghodratzade
                wrote on last edited by
                #7

                in first program you use more variable

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups