This page contains various implementations of different Binary Search Trees (BSTs).
Both bst.py and avl.py (as well as bstsize.py) can be tested interactively from a UNIX shell as follows:
Alternatively, you can use them from a Python shell as follows:
>>> import bst >>> t = bst.BST() >>> print t >>> for i in range(4): ... t.insert(i); ... >>> print t 0 /\ 1 /\ 2 /\ 3 /\ >>> t.delete_min() >>> print t 1 /\ 2 /\ 3 /\
>>> import avl
>>> t = avl.AVL()
>>> print t
>>> for i in range(4):
... t.insert(i);
...
>>> print t
1
/ \
0 2
/\ /\
3
/\
>>> t.delete_min()
>>> print t
2
/ \
1 3
/\ /\