public static int binarySearch(int[] arr, int low,int high,int key){
        int mid;
        while(low<=high){
            mid=(low+high)/2;
            if(key>arr[mid])
                low=mid+1;
            else if(key<arr[mid])
                high=mid-1;
            else
                return mid;
        }
        return low;
    }