private void sink(int k){

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

            if(minIndex == k) return;

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