Heaps not only include binary heaps, but also triple heaps and other multi-forked heaps. The reason why elements must be reordered every time they are inserted into the heap is because of the characteristics of the heap itself. If a binary heap is a minimum heap, then every time The two child nodes of a node should both be larger than itself. When all nodes in the heap are less than or equal to its two child nodes, the heap is in order; when you insert a new node, this order of the heap will be destroyed. status, so it needs to be reordered. As for the Java implementation version, you can search it online. It is easy to find. The heap implementation of JDK is the java.util.PriorityQueue class. You can check it out
Heaps not only include binary heaps, but also triple heaps and other multi-forked heaps. The reason why elements must be reordered every time they are inserted into the heap is because of the characteristics of the heap itself. If a binary heap is a minimum heap, then every time The two child nodes of a node should both be larger than itself. When all nodes in the heap are less than or equal to its two child nodes, the heap is in order; when you insert a new node, this order of the heap will be destroyed. status, so it needs to be reordered. As for the Java implementation version, you can search it online. It is easy to find. The heap implementation of JDK is the java.util.PriorityQueue class. You can check it out