** For COP3530 AVL Trees **
Note that this only works well for a few layers, it will break for larger trees
- Add visualizer.cpp and visualizer.h to your src folder; include it in main.cpp
#include "visualizer.cpp"- These files are dependent on naming conventions and assume that:
- Your tree class is named MyAVLTree
- Your node class is named TreeNode
- Your node's right and left pointers are named "right" and "left"
- Your node's data is named "id" and "name"
- For this to work correctly, do a search and replace on these files to make the names consistent with your tree class
- You must add a public get method to the MyAVLTree class that returns your tree's root
public:
TreeNode *getRoot(){return this->root;}How to use the visualizer:
#include <Windows.h>
TEST_CASE("BST Visualize", "[flag]"){
MyAVLTree tree;
tree.insert(22222222, "Bob");
tree.insert(44444444, "David");
tree.insert(11111111, "Andy");
tree.insert(33333333, "Clyde");
tree.insert(55555555, "Eleanor");
const visualizer<int> v(tree);
cout << endl << endl;
v.visualize();
cout << endl << endl;
system("Pause");
}Adding a system pause helps if you click the exe directly instead of using a terminal
What it looks like for AVL trees:

This program helps to Visualize Binary Search Trees using ASCII characters with the Adaptive Node Length with Fixed Space Length Algorithm — see my Study Case for more info.
