private void sink(int k){

        while (2 * k <= size){
            int maxIndex = k;
            if(arr[2*k] > arr[k]) maxIndex = 2 * k;
            if(2 * k + 1 <= size && arr[2*k+1] > arr[maxIndex]) maxIndex = 2*k + 1;

            if(maxIndex == k) return;

            swap(maxIndex, k);
            k = maxIndex;
        }
    }