Write the algorithm in Find intersection of two sorted integer arrays when one array is very large in size than the other one.
When one array is very large and the other one is very small we can use binary search. Suppose array1 [ ] has m and array2 [ ] has n number of elements respectively where m < < n . We can iterate through array1 [ ] (since it has less number of elements) and binary search for that element in array2 [ ]. public static void findIntersectionOflargearray(int[] array1, int[] array2, int m, int n) { |