title: best-case and worst-case running times in theta notation
body: <p>I am not looking for the answer here but just how to find the worst/best case of the following problem (in theta notation); for loops are generally (theta(n)), which would make the best and worst case that but I think something else is going on here. Any help would be appreciated.</p>
  
  <pre><code>Input: x (an integer), n (an integer)
  addOnes(x, n) {
      if x &gt; n then 
          for i &lt;- 1 to n 
              return x + n
      else 
          for i &lt;- x to n
                  x &lt;- x + n
      return x
  </code></pre>
  
  <p>Edit Answer:</p>
  
  <p>Because of return x + n the constant (theta(1)) would be the best.</p>
  
  <p>Best = (theta(1))
  Worst = (theta(n))</p>