private void sink(int i) {
        while (2 * i + 1 <= N) {
            int index = 2 * i + 1;
            if (index + 1 <= N && pq[index].compareTo(pq[index + 1]) > 0) {
                index = index + 1;
            }
            if (pq[i].compareTo(pq[index]) > 0) {
                T temp = pq[index];
                pq[index] = pq[i];
                pq[i] = temp;
                i = index;
            } else {
                break;
            }
        }
    }