title: Binary search over 2d array to find a local maximum? What's wrong with this algorithm?
body: <p>This is the classic finding a local maximum (just one) in a matrix.</p>
  
  <p>My algorithm is:</p>
  
  <ul>
  <li>Choose the number in the center of the matrix.</li>
  <li>Check if the number is a peak. If yes, return.</li>
  <li><p>If not, check the numbers to the left and right. If one of them is greater than our current number, choose that half of the matrix. If both are greater, we can choose either half.</p></li>
  <li><p>Repeat with the numbers to the top and bottom. This will leave us with one quadrant of the matrix to continue checking.</p></li>
  </ul>
  
  <p>Since this is binary search for a n x n matrix which has n^2 elements, it should take O(log(n^2)) = O(2*log(n)) = O(log(n))</p>
  
  <p>I'm pretty sure this is not correct, but where is my mistake?</p>