Complexity Table for Data Structure
| Unsorted | Sorted by Key | Linked List | Hash Table | Tree | |
|---|---|---|---|---|---|
| lookup | O(n) | O(log(n)) | O(n) | O(1) avg. amt | O(log(n)) |
| insert | O(1) amt | O(n) | O(1) | O(1) avg. amt | O(log(n)) |
| find_min | O(n) | O(1) | O(n) | O(n) | O(log(n)) |
But a tree can be a linked list in worst case.

inner node: middle
root: base node
leaf: end of node
sub-tree: sub tree
left child: child on the left
right child: child on the right
their parent: parent of left and right child
height: the length of the longest path from the root to a leaf
A tree can be:
empty tree: EMPTY (defined by T==NULL)
or a root with a tree on its left and right (empty tree is a tree)

Edge Cases of Checking Valid Trees

you can check it by using sets of visited nodes
More specification: is_tree() && is_ordered().
Check Ordered:


Inserting into BST

It is not sufficient to re-use the old dictionary library

return type should be tree
we should allow NULL node

Table of Content