title: Median of 5 sorted arrays
body: <p>I am trying to find the solution for median of 5 sorted arrays. This was an interview questions. </p>
  
  <p>The solution I could think of was merge the 5 arrays and then find the median [O(l+m+n+o+p)]. </p>
  
  <p>I know that for 2 sorted arrays of same size we can do it in log(2n). [by comparing the median of both arrays and then throwing out 1 half of each array and repeating the process]. .. Finding median can be constant time in sorted arrays .. so I think this is not log(n) ? .. what is the time complexity for this ?</p>
  
  <p>1] Is there a similar solution for 5 arrays . What if the arrays are of same size , is there a better solution then ?  </p>
  
  <p>2] I assume since this was asked for 5, there would be some solution for N sorted arrays ?</p>
  
  <p>Thanks for any pointers. </p>
  
  <p>Some clarification/questions I asked back to the interviewer:<br>
  Are the arrays of same length<br>
  => No<br>
  I guess there would be an overlap in the values of arrays<br>
  => Yes</p>
  
  <p>As an exercise, I think the logic for 2 arrays doesnt extend . Here is a try:<br>
  Applying the above logic of 2 arrays to say 3 arrays:
  [3,7,9] [4,8,15] [2,3,9] ... medians 7,8,3<br>
  throw elements [3,7,9] [4,8] [3,9] .. medians 7,6,6<br>
  throw elements [3,7] [8] [9] ..medians 5,8,9 ...<br>
  throw elements [7] [8] [9] .. median = 8 ... This doesnt seem to be correct ?</p>
  
  <p>The merge of sorted elements => [2,3,4,7,8,9,15] => expected median = 7</p>