public static void main(String args[]){
        int arr[] = {6, 2, 1, 6, 8, 9, 6};
        KthElementInArray kthElement = new KthElementInArray();
        System.out.print(kthElement.kthElement(arr, arr.length/2));
        System.out.print(Arrays.toString(arr));
    }
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