title: Enhanced Binary Search
body: <p>I am doing interview prep questions and have come across this problem: <strong>Search an element in a sorted and rotated array.</strong></p>
  
  <p>The most obvious solution to me is to <strong>1)</strong> find the pivot point (where the number is greater than the next number), and <strong>2)</strong> use that as a dividing point to know which half of the rotated and sorted array to execute binary search.</p>
  
  <p>I found a "better" (or so they claim in geeks for geeks) solution. So as to not bore you with code, here is the high level idea. My question is: <strong>I don't understand how finding the middle point let's us search in only one pass.</strong> Is this honestly any better than the initial solution I came up with? </p>
  
  <p>High level "improved/better" approach:</p>
  
  <pre><code>1) Find middle point mid = (l + h)/2
  2) If key is present at middle point, return mid.
  3) Else If arr[l..mid] is sorted
      a) If key to be searched lies in range from arr[l]
         to arr[mid], recur for arr[l..mid].
      b) Else recur for arr[mid+1..r]
  4) Else (arr[mid+1..r] must be sorted)
      a) If key to be searched lies in range from arr[mid+1]
         to arr[r], recur for arr[mid+1..r].
      b) Else recur for arr[l..mid] 
  </code></pre>