Median of two sorted arrays of same length

suppose we have two arrays

a b c d

e f g h

they are sorted
we need to find the median

we know that m1<m2

i.e.
(b+c)/2 < (f+g)/2

so in the new recursive call do we need to consider b & g as possible candidates???

Then the median will lie within b and g. So even if you consider them both…it will not cause any problem…recursion will handle it.


You can refer this video…all cases have been explained.
1 Like