Find The Median Of Two Sorted Arrays Of Different Size. Let say you have 2 arrays A and B of size n. Take the average of the elements at indexes n-1 and n in the merged array.
So the element from the smaller array will affect the median if and only if it lies between m2 1th and m2 1th element of the larger array. 10 13 14 20 25 The median of two different size arrays are. Arr1 -5 3 6 12 15.
Median of two different sized sorted arrays.
We used a simple Merge based O n solution just we are not merging the array instead we are keeping track of the last element read till we reach the median There are two cases. Bn2 you would do the exact reverse. 6 If size of the two arrays is 2 then use below formula to get the median. Ar1 -5 3 6 12 15 ar2 -12 -10 -6 -3 4 10 The merged array is.
