Heapify Subtree

Objective

The objective of this experiment is to Convert the given Complete Binary Tree into a Max Heap.

Experiment Setup

The Heapify Subtree experiment consists of a Complete Binary Tree. You can click on any "Incorrect" node to select it. You can select only one node at a time.

On selecting an "Incorrect" node, you can correct it by clicking on "Heapify" button. This node will be corrected and the child node with the highest value will be highlighted. You have to keep clicking on "Heapify" button to correct the subsequent child nodes untill you reach a leaf node or a correct node. This process can be called as "Processing a sub-tree rooted at selected node."

Root is highlighted in red color and subsequent child nodes in green color.

After selecting an "Incorrect" node , you cannot select any other node till you either reach the leaf node or a Correct node.

Procedure

  1. Select a incorrect node.
  2. Correct the selected node by clicking on Heapify button.
  3. Process the next node in the current sub-tree. Repeat this step until you have either reached the leaf node or a correct node.
  4. Check if the Complete Binary Tree is also a Max Heap. If not, Repeat steps 1 to 3.