title: Median of two sorted array
body: <p>Here I have written code for  finding median of two sorted arrays:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  #define L  5
  #define  M 6
   const int N=L+M;
  int A[1000];//define 1 indexed aarray
  int B[1000];
  int max(int c,int d){
      return (c&gt;=d)?c:d;
  
  }
  int min(int c,int d)
  {
      return (c&lt;=d)?c:d;
  }
  
  void  read(){
      cout&lt;&lt;" enter A array "&lt;&lt;endl;
      for (int i=1;i&lt;=L;i++)
          cin&gt;&gt;A[i];
      cout&lt;&lt;endl;
      cout&lt;&lt;"enter B array  "&lt;&lt;endl;
      for (int i=1;i&lt;=M;i++)
          cin&gt;&gt;B[i];
      cout&lt;&lt;endl;
  
  
  }
  int median(int a[],int b[],int left,int right){
      if (left&gt;right) {
          return median(b,a,max(1,(N/2)-L),min(M,N/2));
      }
      int i=int(left+right)/2;
      int j=int(N/2)+i;
      if((j==0 || a[i]&gt;b[j]) &amp;&amp; (j==M || a[i]&lt;=b[j+1])){
          return a[i];
      }
      else
      {
          if((j==0 || a[i]&gt;b[j])  &amp;&amp;(j!=M &amp;&amp; a[i]&gt;b[j+1]))
          return median(a,b,left,i-1);
      }
  
  
          return median(a,b,i+1,right);
  
  }
  
  int main(){
  
  
  
  
      return 0;
  }
  </code></pre>
  
  <p>My question is  what could be left and right values? It is from introduction to algorithms, I just don't understand what are values of left and right variables? 
  I have defined left and right as 1 and N and tested with following arrays:</p>
  
  <pre><code>3 5 7 9 11 13
  1 2 4 8 10
  </code></pre>
  
  <p>Answer is 13, which is not correct sure, what is wrong?</p>