/* * C++ Program to Find the median of two Sorted arrays using Binary Search approach */ #include #include #include using namespace std; int min(int a, int b) { int x; if (a < b) { return a; } else { return b; } } int max(int a, int b) { int x; if (a > b) { return a; } else { return b; } } int getMedian(int *ar1, int *ar2, int n) { int x, i, j; if (n == 1) { x = (max(ar1[0], ar2[0]) + min(ar1[1], ar2[1]))/2; cout<<"\n"< ar2[i]) { for (j = 0; j <= i; j++) { temp1[j] = ar1[j]; temp2[j] = ar2[i + j]; } } getMedian(temp1, temp2, i); } } int main() { int i, x, j; cout<<"enter the no of elements to be entered\n"; cin>>i; int *ar1 = new int[i]; int *ar2 = new int[i]; cout<<"enter elements of array 1"<>ar1[j]; } cout<<"enter elements of array 2"<>ar2[j]; } getMedian(ar1, ar2, i); getch(); } /* enter the no of elements to be entered 5 enter elements of array 1 1 2 15 26 38 enter elements of array 2 2 13 17 30 45 16