How can one find a median of 2 sorted arrays A and B which are of length m and n respectively. I have searched, but most the algorithms assume that both arrays are of same size. I want to know how can we find median if m != n consider example, A={1, 3, 5, 7, 11, 15} where m = 6, B={2, 4, 8, 12, 14} where n = 5 and the median is 7
Any help is appreciated. I am preparing for interviews and i am struggling with this algo right now.
Here is the JAVA code to find the median of two sorted arrays of unequal length
A linear search for the median'th ordered element would be O(m + n) with constant space. This isn't optimal, but it's realistic to produce in an interview.