private void swap(int arr[],int low,int high){
        int temp = arr[low];
        arr[low] = arr[high];
        arr[high] = temp;
    }
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