Order Parent Child

Objective

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

Experiment Setup

In the previous experiment, we converted a Complete Binary Tree to a Max heap by swapping any two nodes that have parent-child relationship between them. In this experiment, a restriction has been added on top of previous restriction that the swap operation can only be performed between two nodes if the value of parent node is smaller than the value of child node.

You can click on any node to select/deselect it. You can select at most two nodes at a time. The selections are reset after each swap operation.

Procedure

  1. Select first node.
  2. Select second node.
  3. Swap the selected nodes.
  4. Check if the Complete Binary Tree is also a Max Heap. If not, Repeat steps 1 to 3.