Binary Tree
Tree Nodes
Tree Traversal
BFS
implement a queue
DFS
implement a stack
Pre-order
node,l. subtree, r. subtree
In-order
l.subtree, node, r.subtreethe left subtree contains values less than the root
Post-order
l.subtree, r.subtree, node
BST Definition
l. subtree contains values < root
r. subtree contains values >= to the root
l. & r. subtree are BST
insert: log(n) search: log(n)
Example of DFS using a adjacency list with itera
Using a node implementation with iteration:
Last updated