private int quickSelect(int arr[],int low,int high){
        int pivot = low;
        low++;
        while(low <= high){
            if(arr[pivot] > arr[low]){
                low++;
                continue;
            }
            if(arr[pivot] <= arr[high]){
                high--;
                continue;
            }
            swap(arr,low,high);
        }
        if(arr[high] < arr[pivot]){
            swap(arr,pivot,high);
        }
        return high;
    }
Kth largest element in an array.
Use quickselect of quicksort to find the solution in hopefully O(nlogn) time.
Test cases
Sorted array
Reverse sorted array
src/com/interview/array/KthElementInArray.java