The goal of this exercise is to maintain a valid binary heap through a sequence of calls to Insert and to RemoveMin. As the user, you will be responsible for properly carrying out the "upheap" and "downheap" swapping when necessary. (we assume that you have already been introduced to these concepts!)
When processing an Insert, the newly inserted element will be highlighted in orange. If you choose, you may click on the current element's parent to have those items swap places. When you feel the highlighted element is properly placed, click on the "Validate" button to continue.
When processing a RemoveMin, the demo will assume that the min key is at the root of the heap, and thus will remove this key, replacing it in the structure with the bottom-most item. You are to fix up the heap property at this point. The currently (misplaced?) element is highlighted in orange. If you choose, you may click on either of the current element's children to have the items swap places. When you feel the highlighted element is properly placed, click on the "Validate" button to continue.
After you finish processing each operation, the demo will automatically validate the current heap, showing you any existing violations.
Credits: This software was originally designed as a Java applet by Michael Goldwasser. The current version of this software was implemented in 2015 by Nick Lewchenko using Haskell with the JQuery and Canvas libraries from the GHCJS project as well as the Reactive-banana library. The source code for the project is hosted at https://github.com/RoboNickBot/interactive-tree-demos.