We are given three sorted arrays and we need to find the elements that are common to the three arrays.
Output: 20 80
Here we use binary search to check if the element is present in the array or not. We iterate only the first array and check if each element in the first array is present in other two arrays. The function 'binarySearch()' returns 'true' if the element is found in any of the array and at last if all the three arrays does contain the element, then that element is printed.
Output: 20 80
Here we use binary search to check if the element is present in the array or not. We iterate only the first array and check if each element in the first array is present in other two arrays. The function 'binarySearch()' returns 'true' if the element is found in any of the array and at last if all the three arrays does contain the element, then that element is printed.
No comments:
Post a Comment