title: How do you determine the Big-O notation of a while loop?
body: <p>Below is a binary search function.</p>
  
  <pre><code>int search(int a[], int v, int left, int right)
  {
      while (right &gt;= left)
      {
          int m = (left + right)/2;
          if (v == a[m]) 
              return m;
          if (v &lt; a[m])
              right = m - 1;
          else left = m + 1;
      }
      return -1;
  }
  </code></pre>
  
  <p>How do I determine the Big-O notation for this function? </p>
  
  <p>Is this search function O(n) since the while loop is dependent on the value of <em>left</em>?</p>