Binary HeapSort and Ternary HeapSort implementation This is my take on binary and ternary heapsort implementation for a university assignment. The code works but I wonder if there are any mistakes or things to improve.

class HeapSorter {

    static int[] array;
    static int heapSize;

    //=============================BINARY HEAPSORT=============================//

    static void maxHeapify(int i){

        int leftChild = left(i);
        int rightChild = right(i);
        int largest;

        largest = leftChild &lt;= heapSize &amp;&amp; array[leftChild] &gt; array[i] ? leftChild : i ;

        if(rightChild &lt;= heapSize &amp;&amp; array[rightChild] &gt; array[largest])
            largest = rightChild;


        if(largest != i){
            swap(i, largest);

            //Recursively heapify the subtree
            maxHeapify(largest);
        }


    }

    static void binaryHeapSort(int[] toSort){
        array = toSort;
        buildMaxHeap();

        //testing i &gt;= 0 will be executed for i= array.length - 1, array.length - 2,......0,-1. So array.length + 1 times (n + 1)
        //i-- will be executed array.length times (n)
        for(int i = array.length - 1; i &gt;= 0; i--){

            //swap executed n times (n)
            swap(0,i); 

            // heapSize - 1 executed n times (n)
            // assignment executed n times (n)
            heapSize = heapSize - 1; 

            //maxHeapify executed n times (n)
            maxHeapify(0); 
        }

    }

    static void buildMaxHeap(){
        heapSize = array.length - 1;
        for(int i = (array.length - 1) / 2; i &gt;= 0; i--)
            maxHeapify(i);

    }

    static int left(int i){
        return i &lt;&lt; 1;
    }

    static int right(int i){
        return (i &lt;&lt; 1) + 1;
    }

    //==========================================================================//

    //=============================TERNARY HEAPSORT=============================//

    static void buildMaxHeapT(){
        heapSize = array.length - 1 ;
        for(int i =array.length - 1  / 3; i &gt;= 0; i--)
            maxHeapifyT(i);

    }

    static void maxHeapifyT(int i){

        int leftChild = leftT(i);
        int rightChild = rightT(i);
        int middleChild = middleT(i);
        int largest;

        largest = leftChild &lt;= heapSize &amp;&amp; array[leftChild] &gt; array[i] ? leftChild : i;

        if(rightChild &lt;= heapSize &amp;&amp; array[rightChild] &gt; array[largest])
            largest = rightChild;

        if(middleChild &lt;= heapSize &amp;&amp; array[middleChild] &gt; array[largest])
            largest = middleChild;


        if(largest != i){
            swap(i, largest);
            maxHeapifyT(largest);
        }
    }

    static void ternaryHeapSort(int[] toSort){
        array = toSort;
        buildMaxHeapT();

        for(int i = array.length - 1; i &gt;= 0; i--){
            swap(0,i); //add last element on array, i.e heap root

            heapSize = heapSize - 1; //shrink heap by 1
            maxHeapifyT(0);
        }

    }

    static int leftT(int i){
        return 3 * i + 1;
    }

    static int middleT(int i){
        return 3 * i + 2;
    }

    static int rightT(int i){
        return 3 * i + 3;
    }

    //==========================================================================//



    static void swap(int i, int j){
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }




    static int[] start (int[] toSort, boolean binaryHeap) {
        if (binaryHeap) {
            binaryHeapSort(toSort);
        } else { 
            ternaryHeapSort(toSort);
        }

        return toSort;
    }
}


Also, should I use bit shifting like this:

static int leftT(int i){
    return (i &lt;&lt; 1) + i + 1;
 }


instead of 

static int leftT(int i){
    return 3 * i + 1;
}
It's not bad. And I'm lazy, so just two comments:

static int[] array;


No statics should be ever used except for constants. Please always create an object, ideally assign everything in the constructor, and let it work on its data.

It's just a few lines more and it makes your class much more usable. Statics are sort of global variables, which means bad. The way you did it, it works... but try to start more threads and call start concurrently.


  Also should i use bit shifting like this: 


No, except maybe on Android. Let the JVM do its work. It probably knows much more tricks than you (e.g., doing x / 10 without division instruction, i.e., maybe 3 times faster).