public double median(int arr1[],int arr2[]){
        int low1 = 0;
        int high1 = arr1.length-1;
        
        int low2 = 0;
        int high2 = arr2.length-1;

        while(true){
            
            if(high1 == low1){
                return (arr1[low1] + arr2[low2])/2;
            }
            
            if(high1 - low1 == 1){
                return (double)(Math.max(arr1[low1], arr2[low2]) + Math.min(arr1[high1], arr2[high2]))/2;
            }
            
            double med1 = getMedian(arr1,low1,high1);
            double med2 = getMedian(arr2,low1,high2);
            if(med1 <= med2){
                if((high1-low1 + 1) % 2 == 0){
                    low1 = (high1+low1)/2;
                    high2 = (high2+low2)/2 + 1;
                }else{
                    low1 = (low1+high1)/2;
                    high2 = (low2+high2)/2;
                }
            }
            else{
                if((high1-low1 + 1) % 2 == 0){
                    low2 = (high2+low2)/2;
                    high1 = (high1+low1)/2 + 1;
                }else{
                    low2 = (low2+high2)/2;
                    high1 = (low1+high1)/2;
                }
            }
        }
    }
http://www.geeksforgeeks.org/median-of-two-sorted-arrays/
src/com/interview/binarysearch/MedianOfTwoSortedArray.java