During the Data Structure and Algorithms course, the Tree that implemented is not visible, which cause difficulties in debugging. This project implement a visualizer to real-time visualize the tree, make it easy to debug and learn the Tree structure.
The Node class used by your tree should be exactly the same as the one in the Tree.java of this project.
The visualizer depends on Processing.core, add Processing.core to your build path manually or using Maven to build
If you are using Maven, add following to pom.xml
<dependencies>
<dependency>
<groupId>org.processing</groupId>
<artifactId>core</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
The version of processing used is Processing 2.2.1. If you are using processing 3 or above, in the Visualizer class, you should change the setup() method name to settings() like following.
public void settings() {
size(width, height);
}
Except the Node class, you do not need further modify your code. You can simply pass your Tree instance to the static fields in the Visualizer class.
Tree t = new Tree();
Visualizer.treeVisualize(t);
Like Heap data structure implemented using array, you can call the heapVisualize() method. The heapVisualize() method will parse array into Node Tree, and pass to the treeVisualizer. The only requirement is your array should stratify the format such that the first element(index 0) should store the count of elements stored in the array. The heapVisualize() only support integer data type.
int[] treeArray = {5,1,2,3,4,5}; //The first element 5 indicates the element count
Visualiezer.heapVisualize(treeArray);
- Maven - Dependencies Management
- Processing - External library
- Yifeng Carter CHENG - Initial work - Cyfine
This project is licensed under the Apache License 2.0 - see the LICENSE file for details