title: find median of two sorted arrays - I get stackoverflow exception
body: <p>The problem is given <code>two sorted Arrays</code>, find the <code>median</code> of the two in <code>O(log n)</code>. merging the sorted arrays and finding the median (at n/2) should work.but that is <code>O(n)</code> time I guess and it requires an auxillary storage. I found this <a href="http://www.csee.umbc.edu/~kalpakis/courses/441-sp03/hws/hw4-sol.pdf" rel="nofollow">pseudocode</a>(problem 2 in the pdf). when I implement that code, I get <code>stackoverflow exception</code>. Here is my code:</p>
  
  <pre class="lang-c prettyprint-override"><code>public static int quickMedian(int[] arr1, int[] arr2, int startArr1, int endArr1, int startArr2, int endArr2){  
          int m1=(endArr1-startArr1)/2;
          int m2=(endArr2-startArr2)/2;
          if (arr1[m1]==arr2[m2])
              return arr1[m1];
          if (arr1[m1]&lt;arr2[m2])
              return quickMedian(arr1, arr2, m1, endArr1, startArr2, m2);
          else 
              return quickMedian(arr1, arr2, startArr1, m1, m2, endArr2);
      }
  
  public static void main (String[] args){
          int[] arr1={1,3,5,7};
          int[] arr2={2,4,6,8};
          int[] arr3={1,2,4,6,8,10,11};
          System.out.println(quickMedian(arr1, arr2, 0, arr1.length-1, 0, arr2.length-1));
      }
  </code></pre>
  
  <p>I need help fixing <code>stackoverflow exception</code> and make this work. Thanks.</p>