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. Other Discussions
  3. IT & Infrastructure
  4. A program to compute for Big Oh

A program to compute for Big Oh

Scheduled Pinned Locked Moved IT & Infrastructure
question
9 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.
  • I Offline
    I Offline
    Ian Uy
    wrote on last edited by
    #1

    Good Day, Is there a program that can compute for Big Oh notations? I mean, I just paste the code segment and it will generate the Big Oh notation for that segment. Thanks! :-D

    It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.

    P P 2 Replies Last reply
    0
    • I Ian Uy

      Good Day, Is there a program that can compute for Big Oh notations? I mean, I just paste the code segment and it will generate the Big Oh notation for that segment. Thanks! :-D

      It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I thought you were talking about me here. (My nickname at school was the Big O - being 6 foot at 13 year old).

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      1 Reply Last reply
      0
      • I Ian Uy

        Good Day, Is there a program that can compute for Big Oh notations? I mean, I just paste the code segment and it will generate the Big Oh notation for that segment. Thanks! :-D

        It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Not sure if there is one, but it wouldn't be that hard to implement :)

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        D 1 Reply Last reply
        0
        • P Paul Conrad

          Not sure if there is one, but it wouldn't be that hard to implement :)

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          D Offline
          D Offline
          Daniel Grunwald
          wrote on last edited by
          #4

          Paul Conrad wrote:

          but it wouldn't be that hard to implement

          So what would the output be for this function?

          int F(int n)
          {
          // assume n > 0
          int c = 0;
          while (n != 1) {
          if ((n % 2) == 1) // n odd
          n = 3 * n + 1;
          else // n even
          n = n / 2;
          c++;
          }
          return c;
          }

          P 1 Reply Last reply
          0
          • D Daniel Grunwald

            Paul Conrad wrote:

            but it wouldn't be that hard to implement

            So what would the output be for this function?

            int F(int n)
            {
            // assume n > 0
            int c = 0;
            while (n != 1) {
            if ((n % 2) == 1) // n odd
            n = 3 * n + 1;
            else // n even
            n = n / 2;
            c++;
            }
            return c;
            }

            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #5

            Your function is of O(n)...

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

            D 1 Reply Last reply
            0
            • P Paul Conrad

              Your function is of O(n)...

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

              D Offline
              D Offline
              Daniel Grunwald
              wrote on last edited by
              #6

              Do you have a proof for that? You might want to read http://en.wikipedia.org/wiki/Collatz_conjecture[^] Edit: maybe you are right, I should have written BigInteger instead of int...

              P 1 Reply Last reply
              0
              • D Daniel Grunwald

                Do you have a proof for that? You might want to read http://en.wikipedia.org/wiki/Collatz_conjecture[^] Edit: maybe you are right, I should have written BigInteger instead of int...

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #7

                The line count through the execution does bounce fluctuate like the graph on the wiki article. Throwing the values into a excel spreadsheet and doing a trendline and equation is rather sketchy.

                "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                D 1 Reply Last reply
                0
                • P Paul Conrad

                  The line count through the execution does bounce fluctuate like the graph on the wiki article. Throwing the values into a excel spreadsheet and doing a trendline and equation is rather sketchy.

                  "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  D Offline
                  D Offline
                  Daniel Grunwald
                  wrote on last edited by
                  #8

                  It's O(n) only if it terminates at all. Which is still unproven. What happened to your first answer? It disappeared and took my response with it. I won't repeat it here, but basically I think that even if you restrict yourself to terminating programs, you can construct cases where the running time can be determined only by solving some unsolved math problem.

                  P 1 Reply Last reply
                  0
                  • D Daniel Grunwald

                    It's O(n) only if it terminates at all. Which is still unproven. What happened to your first answer? It disappeared and took my response with it. I won't repeat it here, but basically I think that even if you restrict yourself to terminating programs, you can construct cases where the running time can be determined only by solving some unsolved math problem.

                    P Offline
                    P Offline
                    Paul Conrad
                    wrote on last edited by
                    #9

                    Original post was a bit off. Seems like no one knows for sure if the Collatz Conjecture does. I remember my algorithms teacher talking about it. If there were to be a program that you could just feed in a code snippet and it returns whatever the Big O is for the code snippet, one would have to make the assumption the code does terminate and is in simple form. This would have to lead into defining what is actually simple?

                    "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                    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