Binary Search Tree
Introduction
This is just a quick coding project I did for fun.
One unique thing about this project is that, in addition to creating an un-balanced BST implementation, I also created a compact graph layout and visualization engine.
(Here is the Wikipedia BST page.)
Graph Layout Algorithm
In order to validate the BST operations such as add() and remove(), I decided to develop a BST graph layout algorithm to visualize the effects these operations had on the graph. This particular layout algorithm is designed to support nodes of varying widths.
(Note: Even though there are algorithms published in the literature for this sort of layout algorithm, I developed this algorithm completely from scratch in order to give my brain some exercise.)
Essentially, the layout algorithm positions node centroid x-coordinates a minimum distance to the right of their predecessor nodes. And, for nodes at the same depth, it ensures they do not overlap while also enforcing a minimum node spacing constraint. When there is a range of x-coordinates a node can legally occupy without violating spacing or ordering constraints, the layout algorithm places the node in the center of this range.
Below is an informal graphical diagram containing more details of the layout algorithm: