Trying to understand max heapify

Here’s what MAX-HEAPIFY does: Given a node at index i whose left and right subtrees are max-heaps, MAX-HEAPIFY moves the node at i down the max-heap until it no longer violates the max-heap property (that is, the node is not smaller than its children). The longest path that a node can take before it is in the proper position … Read more

Is there a maxheap in the C++ standard library?

Regarding std::priority_queue: A user-provided Compare can be supplied to change the ordering, e.g. using std::greater<T> would cause the smallest element to appear as the top(). Since std::less<T> is the default template argument to the Compare template parameter, it is already a max heap by default. If you want a min heap instead (what the quote above suggest), pass std::greater<T> instead of std::less<T> as the template argument. To summarize: Max Heap: pass std::less<T> (this is the default template … Read more