Answer the question
In order to leave comments, you need to log in
PriorityQueue implementation?
Do I understand correctly that Java uses a binary heap as a data structure in PriorityQueue, and specifically the implementation of max-heap?
Judging by the description of the siftUp method inside the class:
Inserts item x at position k, maintaining heap invariant by promoting x up the tree until it is greater than or equal to its parent, or is the root.
Those. ensures that the added element moves up the tree as long as it is greater than or equal to its parent, and if so, does it mean that the maximum element sits at the root?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question