Basic Play

Keys do the following:

  1. Swap first with last and freeze (Phase 2 only)
  2. Swap with the left child
  3. Swap with the right child
  4. Start the next sub-heap (Phase 1 only)

Control

  1. Reset the game
    1. Toggle on/off a threshold setting of 3

    This simulates single-user interaction using an i>Clicker. In a classroom situation multiple students could play in a team where a majority would need to agree on each move by clicking the appropriate button.

Click on the white background to start the gamelet.

Instructions:

Your goal is to sort the array into increasing order using HeapSort. This is done in two phases, with the operations listed below (summary on the left). The “current node” is shown in green; its children are in yellow. Nodes in grey are “frozen", which means (in Phase 1) they are not yet part of the heap or (in Phase 2) they have been taken out of the heap because they have their final content. Nodes in purple show the path in to the current node in the current sub-heap. Nodes in black are in the heap but have not been visited (as yet).

In Phase 1 we build a max-heap (largest element at the top) starting at the last element in the heap and working up to the root.

In Phase 2 we move the elements from the top the heap into their final positions by swapping them with the last element currently in the heap.

Type “a” to swap the content of the top (root) node with the last node in the heap during Phase 2 so that content is in its final position. This key is not used during Phase 1.

Type “b” to swap the content of the current node with the content of its left child (either phase).

Type “c” to swap the content of the current node with the content of its right child (either phase).

Type “d” to move to the next sub-heap during Phase 1 (move to the left of the node that starts the current sub-heap or move up and to the far right if the current sub-heap is at the far left). This key is not used during Phase 2.

The “e” key is never used by this gamelet.

To start, click on the applet window to start, then type keys to simulate i>Clicker key presses.

For multi-game competition, use UPPER CASE characters for the right game and regular lower case for the left game. If two keyboards are available, one keyboard can be used for each game.

To simulate team-base play, toggle thresholding to be “on” using the 't' key so that three matching key presses are required to initiate an operation. In a classroom situation this would mean that the students had reached a consensus on the next move.

Source code: heap

Built with Processing