private static void maxHeapify(Comparable[] arr, int i, int n){

        //getting the left node of this node
        //while the j is less than the size of the array
        while(i*2+1<n) {
            int j = i*2+1;
            //checking if the right is less than the left node
            //if not then choose the right to be the parent node instead of i
            if(j+1<n && arr[j].compareTo(arr[j+1]) < 0)
                j++;
            //if the i node is greater than the child node then everythng is ok and break
            if(arr[i].compareTo(arr[j]) >=0)
                break;
            else{
                //else then we should swap the i and j node
                //setting the parent node to the biggest child of right and left

                Comparable tmp = arr[j];
                arr[j] = arr[i];
                arr[i] = tmp;
                //setting the j to the left child of children to continue the loop
                i = j;
            }
        }
        //when break then we have reached the place where the i node is and we assign it
        return;
    }