The objective of this experiment is to Convert the given Complete Binary Tree into a Max Heap.
Let P be the value of a node, C1 be the value of left child(if any), C2 be the value of right child(in any).
Correct value of a node is P, if no child node exists.
Correct value of a node is max(P,C1), if one child node exists. By definition of a Complete Binary Tree, if only one child exists then it will be the left child.
Correct value of a node is max(P,C1,C2), if two child node exists.
A Node is said to be a "Correct" node if its value is greater than or equal to its children(if they exist). A Leaf node is also a "Correct" node. In other words, if P is equal to the "Correct value of the node" then the node is "Correct".
A Node which is not correct is called an "Incorrect" Node. In other words, if P is not equal to the "Correct value of the node" then the node is "Incorrect".
The Correction Machine experiment consists of a Complete Binary Tree. You can click on any node to select it. You can select only one node at a time. Selecting any node will deselect a previously selected node(if any).
On selecting an Incorrect node, you can correct it by clicking on "Correct" button. This operation will swap the selected node with the node which has the "Correct value" of Selected Node. For example, if P = 64, C1 = 49 and C2 = 100. The correct value of the node is C2(100). After the operation, P and C2 will be swapped. Hence,P = 100, C1 = 49, C2 = 64.