src/com/michaelho/DivideAndConquer/DC2.java
/**
     * This function takes last element as pivot, places the pivot element
     * at its correct position in sorted array, and places all smaller (smaller than pivot)
     * to left of pivot and all greater elements to right of pivot.
     *
     * @param arr The array to be partitioned.
     * @param low The starting index.
     * @param high The ending index.
     *
     * @return The index of the pivot, which is also the final index of the element in sorted array.
     * */
This function takes last element as pivot, places the pivot element
at its correct position in sorted array, and places all smaller (smaller than pivot)
to left of pivot and all greater elements to right of pivot.

@param arr The array to be partitioned.
@param low The starting index.
@param high The ending index.

@return The index of the pivot, which is also the final index of the element in sorted array.
This function takes last element as pivot places the pivot element at its correct position in sorted array and places all smaller ( smaller than pivot ) to left of pivot and all greater elements to right of pivot . @param arr The array to be partitioned . @param low The starting index . @param high The ending index . @return The index of the pivot which is also the final index of the element in sorted array .
private int partition(int[] arr, int low, int high) {
        int right = arr[high];
        int i = (low-1); 
        for (int j = low; j < high; j++) {
            if (arr[j] <= right) {
                i++;
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
        int temp = arr[i+1];
        arr[i+1] = arr[high];
        arr[high] = temp;
        return i+1;
    }
private int partition ( int [ ] arr , int low , int high ) { int right = arr [ high ] ; int i = ( low - 1 ) ; for ( int j = low ; j < high ; j ++ ) { if ( arr [ j ] <= right ) { i ++ ; int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } } int temp = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = temp ; return i + 1 ; }
This function takes last element as pivot, places the pivot element
 at its correct position in sorted array, and places all smaller (smaller than pivot)
 to left of pivot and all greater elements to right of pivot.
This function takes last element as pivot places the pivot element at its correct position in sorted array and places all smaller ( smaller than pivot ) to left of pivot and all greater elements to right of pivot .
// index of smaller element // If current element is smaller than or equal to pivot // swap arr[i] and arr[j] // swap arr[i+1] and arr[high] (or pivot)