Priority Queue - When Prioritizing Take Place?
The underlying data structure is usually a heap, and the elements are partially ordered when it's initialized. At that point, the highest priority element is at the root of the heap ready to be popped next. When a new element is added to the heap it is added at the end and partial ordering is done bottom up; and when an element is removed the last element moved to the root and the partial ordering is done top down. So when implemented using a heap, the prioritization is maintained by partial ordering when initialized and when an element is added or removed.