Algorithm and data structure queue priority

Maximum priority queue

The maximum priority queue is implemented using the heap, because the root element of the heap is the maximum value of all elements in the entire heap.

  Code implementation of the largest priority queue

Basically the code is similar to the heap code

Minimum priority queue

Therefore, the process of floating should first be compared with the child nodes of the same parent node, and then compared with the parent node

The sinking process needs to be compared with one of the child nodes.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_35677589/article/details/112507067