Actually I've also heard of the two terms which are- reheapification upward and reheapification downward. But what is the meaning of max-heapify and min-heapify? Are these two terms(max-heapify and min-heapify) somehow related to reheapification upward and reheapification downward? According to me both reheapification upward and reheapification downward come under max-heapify as well as min-heapify. Please correct me if I'm wrong. Also please tell me the time complexities of all these four terms.
Asked
Active
Viewed 1,651 times
1 Answers
1
reheapification upward is performed when adding an item to a binary heap. When you add an item, you do the following:
- Add the item to the end of the array.
- Move it up in the heap to its proper position. This step is reheapification upward. It's also referred to as "bubble up," "sift up," or "swim."
When you remove the root item from a heap, you do the following:
- Replace the root item with the last item on the heap.
- Move that item down the heap to its proper place. This is reheapification downward. It's also referred to as "bubble down," "sift down," or "sink."
Both operations apply equally to min-heaps and max-heaps.
In a min heap, the function that implements downward reheapfication is often called "min-heapify." In a max heap implementation, that function is often called "max-heapify."
Reheapification upward and reheapfication downward both have complexity O(log n).

Jim Mischel
- 131,090
- 20
- 188
- 351