data you want to delete from the tree
insert a node into the tree
a self reference to the BST
const tree = new BST<number>()
tree.insert(1).insert(2).insert(3)
data you want to insert into the tree
Search for a node with the given value
the node with the data or -1 if not found
const tree = new BST<number>([5, 3, 7, 2, 4, 6, 8, 1, 9, 10]);
tree.search(7); // Node{data:7 ,left:Node{data:6}, right:Node{data:8} }
tree.search(50); // -1
data you want to search for
Logs the tree to the console
a self reference to the BST
const tree = new BST<number>([5, 3, 7, 2, 4, 6, 8, 1, 9, 10]);
tree.view();
// 5
// / \
// / \
// / \
// {3,4,,,2,,1,,} {7,8,9,10,,,,,6,,}
Generated using TypeDoc
Delete a node from the tree
Returns
a self reference to the BST
Example