BSTLearner - An interactive visualization of binary search trees

A binary search tree (BST) is a data structure used for storing, retrieving and sorting data in an efficient way, by using a binary tree structure with the property that the keys in a node’s left subtree are less and the keys in a node's right subtree are greater than the key of the node itself. Binary search trees are best understood using interactive visualizations that show how to insert / search / delete values in a tree, how to create a BST from random numbers, how to perform left and right rotations, traverse the tree etc.

This Jupyter Notebook uploaded to Google Colab features the interactive visualization of binary search trees using Jupyter Notebook Widgets and the graphviz-package. This is work in progress! To be finished as project work by students.

Start the BSTLearner 

BSTLearner Usage

The app has tree tabs, the first one for binary search trees, the second one for AVL-trees (self-balancing trees constructed by using a balancing factor and rotating the tree as needed to restore the balance), the third tab for B-Trees. You can create a new tree either step by step, by entering new keys in the edit field and then clicking "Insert", or by creating an entire tree from random numbers using the button "Random".

BSTLearner Implementation

The nodes of a binary search tree are created using the class TreeNode. Binary search trees are created using the methods of the class BST.