title: Time Complexity of this algorithm?
body: <p>Need help figuring out the time complexity of this algorithm using Big-O notation. Cheers.     </p>
  
  <pre><code>int binarySearch(int[] array, int key) {
      int lo = 0, mid, hi = array.length-1;
      while (lo &lt;= hi) {
          mid = (lo + hi)/2;
          if (key &lt; array[mid])
              hi = mid - 1;
          else if (array[mid] &lt; key)
              lo = mid + 1;
          else return mid; // success
      }
      return -1; // failure
  }
  </code></pre>