T
- Type of elements.
Return type: none
Arguments: T
Inserts a given value to the tree.
Return type: bool
Arguments: T
Returns whether a given value exist in the tree.
Return type: none
Arguments: T
Removes given value from the tree if it exist.
Library include
#include "path/to/Basic-Data-Structures/include/bstree"
BSTree declaration
BSTree<int> l;
Insertion
tree.insert(2);
tree.insert(4);
tree.insert(1);
tree.insert(5);
tree.insert(3);
/*
now tree looks like this:
2
/ \
1 4
/ \
3 5
*/
You can print BSTree using BSTreePrinter class. Library include:
#include "path/to/Basic-Data-Structures/include/bstreeprinter"
Available functions:
static void print(BSTree<T>*);
static void print(BSTree<T>&);
Example:
BSTree<int> t;
// some insert operations here
BSTreePrinter<int>::print(t); // tree object passed by reference
or
BSTreePrinter<int>::print(&t); // tree object passed by pointer