main.java
/*Alexander Papachristu
     * sort function that builds a heap from an inputted array
     * that is sent to the heapify function
     */
Alexander Papachristu
sort function that builds a heap from an inputted array
that is sent to the heapify function
Alexander Papachristu sort function that builds a heap from an inputted array that is sent to the heapify function
public static int[] sort(int arr[])
    {
        int arrLength = arr.length;
        for (int i = arrLength / 2 - 1; i >= 0; i--)
            heapify(arr, arrLength, i);
        for (int i = arrLength - 1; i > 0; i--) {
            int temp = arr[0];
            arr[0] = arr[i];
            arr[i] = temp;
            heapify(arr, i, 0);
        }
        return arr;
    }
public static int [ ] sort ( int arr [ ] ) { int arrLength = arr . length ; for ( int i = arrLength / 2 - 1 ; i >= 0 ; i -- ) heapify ( arr , arrLength , i ) ; for ( int i = arrLength - 1 ; i > 0 ; i -- ) { int temp = arr [ 0 ] ; arr [ 0 ] = arr [ i ] ; arr [ i ] = temp ; heapify ( arr , i , 0 ) ; } return arr ; }
Alexander Papachristu
 sort function that builds a heap from an inputted array
 that is sent to the heapify function
Alexander Papachristu sort function that builds a heap from an inputted array that is sent to the heapify function
//Build heap //Remove an element from the heap // Move current root to the last value of the array