title: Finding point of rotation in the sorted array
body: <p>I am trying to locate the point of rotation in a sorted array through a modified binary search.</p>
  
  <p>Consider this array <code>int values[9]={7, 8, 9, 1, 2, 3, 4, 5, 6};</code>
  The point of rotation here is at index = 3 i.e at 9.</p>
  
  <p>I wrote this function for the above operation. </p>
  
  <pre><code>void FindRotationPoint(int values[], int numvalues)
  {
      int first =0;
      int last = numvalues-1;
      int middle;
      bool moreTosearch= (first&lt;=last);
      while(first&lt;=last)
      {
          middle = (first+last)/2;
          if(values[0]&gt;values[middle]) //Keep looking right if the middle value in array is greater than first
          {
              last = middle-1;
          }
          if (values[0]&lt;values[middle]) //Keep looking left if the middle value in array is less than first
          {
              first = middle+1;
          }
      }
      cout&lt;&lt;middle+1&lt;&lt;endl;
      cout&lt;&lt;values[middle];
  }
  </code></pre>
  
  <p>If the elements are
  <code>int values[9]={7, 8, 9, 1, 2, 3, 4, 5, 6};</code> <strong>Output: 4, 1</strong> (Wrong)</p>
  
  <p><code>int values[9]={7, 8, 9, 10, 2, 3, 4, 5, 6};</code> <strong>Output: 4, 10</strong> (Correct)</p>
  
  <p>The point of rotation which is at an even place is found correct whereas in the other case, it finds the succeeding element. What am I missing in the above code?</p>