This macro takes constant time as well. In other words, the node has a higher priority than its two children and, hence, will not move. In this case, a node with the highest priority is floated to the top from the bottom row. Here, heapsize is the index of the new job in the heap array. This guarantees that the job will not have to float up.
Insertion always places an inserted node as the last element and then floats it towards the top.
Since the the node now has the higest priority, it will have to float to the top of the heap. In this case the job will be heapified all the way to the bottom row. MAX The best and worst cases are the same, because it does one compare and returns a pointer or NULL depending on the compare result. The worst case is still constant time, but requires an additional increment to heapsize and also a swap. We optimized our priority queue for real-world UNIX scheduling tasks.