title: Finding Growth Functions & Big O
body: <p>For each of the following code snippets, I need to state the growth function as well as the order. I'm fairly certain I have the orders determined correctly but I'm struggling to see how an entire function with constants and all can be derived from what I'm provided with. </p>
  
  <p>Here are the pieces of code:</p>
  
  <pre><code>// CODE #1
  for (int count=0; count&lt;n; count++)
  {
      for (int count2=0; count2&lt;n; count2=count2+2)
      {
          System.out.println(count + ", " + count2);
       }
  }
  
  // CODE #2
  for (int count=0; count&lt;n; count++)
  {
      for (int count2=1; count2&lt;n; count2=count2*2)
       {
           System.out.println(count + ", " + count2);
      }     
  }
  
  // CODE #3
  for (int count = 0; count &lt; n; count++) {
      printsum(count); }
  
  // Here’s the method:
  
  public void printsum(int count) {
      int sum = 0;
      for (int i=1; i&lt;count; i++) {
          sum += i; 
      }
      System.out.println(sum + ": " + sum); 
      }
  
  // CODE #4
  for (int count = 0; count &lt; n; count++) 
  {
      printsum(count); 
  }
  
  // Here’s the method:
  
  public void printsum(int count) { 
      int sum = 0;
      sum = count * (count + 1)/2; 
      System.out.println(“sum : " + sum);
  }
  </code></pre>
  
  <p>I think the orders are <code>O(n^2)</code>, <code>O(nlogn (base 2))</code>, <code>O(n^2)</code>, and <code>O(n^3)</code>. If anyone could offer any suggestions on finding the growth functions or correcting my work so far, please let me know.</p>