Subsections


Interaction


Hotspots

Data structures with a visible title have a hotspot in the left corner of the title bar, denoted by a square containing a red ``[^]''. The popup menu can be opened by left-clicking on this hotspot (Section 6).

Arrays contain another hotspot (two-headed arrow) in the right corner of the title bar. The number of elements displayed in the array can be changed by dragging this hotspot left or right.

There are also two additional hotspots. In the top right corner of the CDT structures there is the search hotspot ``(?)'' which can be used to call the search method of the CDT structure by dropping the searched key on the hotspot. In the bottom right corner of structures (except arrays) there is the null hotspot ``(0)'' which can be used to modify references point to empty nodes. To use it, drag and drop a reference to the hotspot and update references from Options menu.

See Figure 2 for examples of the hotspots.

Inserting keys into a data structure

In the example of the binary search tree, we showed how keys can be inserted into a data structure by dropping them onto the title bar of the data structure. The insertion routine of the corresponding data structure will then be invoked and the visualization will be updated. It is also possible to insert a key in a specific node of a data structure, by dragging and droping the new key into the desired node.

For example, create an array of keys and an AVL tree and insert M into the tree. You can now experiment with dragging and dropping another key (say P) either onto the title bar or into the root node or one of the leaves (Fig. 3). In each case the results will be different.

Figure 3: Inserting keys into a specific node or by invoking the insert routine

MatrixPro supports nested data structures of arbitrary complexity. You can store an array inside a node of a graph or a tree in as an array element; for example, the B-tree implementation (2-3-4 Tree) uses arrays nested within trees to hold the keys. Some fundamental data types, such as arrays or binary trees, have no semantics for inserting keys ``into the structure.'' For such structures, keys must be inserted at a specific position; in case of inserting a set of keys, the entire set will be inserted as a unit.


Deleting keys and nodes

Elements can be deleted from a data structures by using the Delete command in the popup menu. What the Delete command actually does depends on the data structure or structure component upon which it was invoked. Deleting a data structure will remove the whole structure, including its visualization from the current frame; it is not possible to undelete it by going backward in the animation. Deleting a tree node removes the subtree rooted at the deleted node, while deleting a graph node causes that node and all references to or from it to be deleted. Deleting a node in a linked list will remove that node from the list. Some components of structures, such as array indices, cannot be deleted.

The effects of deleting a node from a CDT depend on the CDT in question. The two ways to delete an item described above both act as if the deletion were performed on the FDT upon which the CDT is based. A different way to delete an item from a CDT is to hold the Shift key down while dragging the item away from the CDT and dropping it somewhere else (such as an empty part of the animation window). This deletes the item from the CDT, and if the item is dropped on another structure, it is inserted as usual. Note that the CDT's delete routine is used to perform the delete in with Shift held down; for example, Shift-dragging an item from a stack will always cause the topmost item on the stack to be deleted regardless of which item was dragged.

Elements can also be deleted by dragging and dropping them in a trash can, which can be created by selecting Structures/Utilities/Trash.


Other operations

To copy a subtree, drag the root node of the subtree to the desired position. If you copy a subtree to a different position in the same tree, the first subtree (that will be found in a DFS) will be displayed, and the other copies will be shown minimized. The copied tree points to the original tree, so changes in either of the visualizations affect both the original and the copy.

References in graphs and trees can be moved to point to another node by dragging and dropping them on the new target node. Tree nodes that have no references are removed. References must be explicitly updated after a drag and drop operation by selecting Options/Update References.

In MatrixPro operations are grouped into animation steps that can contain other, smaller, steps. The smallest possible steps (atomic steps) may not have any visible effect on the visualizations. Normally, the animation control buttons work on non-atomic steps, but they work on atomic steps if Shift is pressed when selecting Backward or Forward.