Google Interview Question

Find median given two sorted arrays

Interview Answers

Anonymous

Jun 10, 2017

Floor(Length(array1)/2) & Floor(Length(array2/2))

5

Anonymous

Jun 27, 2012

Merge two array like in merge sort(no need to store result.). until you fetch (|A|+|B|) /2 items last item is median

2

Anonymous

Jul 16, 2012

Using a binary search at array A while change the position index at b. The average running time is log(min(m, n)), where m and n are the respective array size.

1