Java PriorityQueue does not store the whole sequence in-order. So if we try to print it using System.out.println(Q), the output will usually not be in-order. But every time we do a poll() on a priority queue, it will give the smallest number in the current sequence.

Leave a Reply

Your email address will not be published. Required fields are marked *