Skip to content

culbrethj/bst-ascii-visualization

 
 

Repository files navigation

BST ASCII Visualization

** For COP3530 AVL Trees **
Note that this only works well for a few layers, it will break for larger trees

  1. Add visualizer.cpp and visualizer.h to your src folder; include it in main.cpp
#include "visualizer.cpp"
  1. 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
  1. 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: Alt text

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

SCREENSHOT

About

A C++ based algorithm for visualizing Binary Search Trees.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%