JMCanning78 / DemoRepo

0 stars 0 forks source link

Archive Create basic BinaryTree visualization based on VisualizationApp #34

Open JMCanning78 opened 4 years ago

JMCanning78 commented 4 years ago

Create a BinaryTree class based on VisualizationApp using the code from Trees.py. Rename Trees.py into BinaryTreeBase.py with a corresponding BinaryTreeBase class that will be used for other binary tree representations (like AVL trees and maybe Heaps). This class should have the basic methods for placing nodes on the canvas. It should use an underlying array representation of the binary tree. See the section on "Trees Represented as Arrays" in 08 Binary Trees.pdf in COMP 1320C Spring 2020 Preview. There should be methods to translate between array indices and canvas coordinates and methods to get the parent, left child, and right child indices from an array index. The position of the root on the canvas, the spacing between levels, and the width allowed for the tree at level 4 should be parameterized. There should be a common way to show the tree root that corresponds to the BinarySearchTree object in the textbook code. The only thing in that object is a (possibly empty) pointer to the root node (so maybe a simple "root:" label would do). There should be common methods for creating and displaying nodes. Nodes should be clickable and populate the argument text with their value (like in Array.py). Links to a parent should be drawn with a single line. Some links will be highlighed to show a selected path in some algorithms. To draw links underneath nodes on the Tk canvas, it will help to put them on a canvas level below that root while nodes are above that level.

Add a new file, BinaryTree.py, that with a BinaryTree class based on BinaryTreeBase and implements the animated methods for:

Animations for these functions are partially built in Trees.py but will need to be refactored between BinaryTreeBase and BinaryTree. Random Fill should be an animation of a sequence of N inserts (not just showing the result).