public int search(int arr[],int search){
        int low =0;
        int high = arr.length-1;
        while(low <= high){
            int mid = (low + high)/2;
            if(arr[mid] == search){
                return mid;
            }
            
            if(arr[mid] < arr[high]){
                if(arr[mid] < search && search <= arr[high]){
                    low = mid+1;
                }else{
                    high = mid-1;
                }
            }else{
                if(search >= arr[low] && search < arr[mid]){
                    high = mid-1;
                }else{
                    low = mid+1;
                }
            }
        }
        return -1;
    }
Duplicates are not allowed in arr.
src/com/interview/binarysearch/SortedAndRotatedArraySearch.java