O(1)
O(log n)
O(n)
O(n log n)
O(n^2)
O(n^3)
O(n^k)
O(k^n)
Full Tree: 0 or two nodes
Complete: Where all the nodes in order must be filled
TODO: Floyd’s
Binary Search Trees
An ordered or sorted binary tree, is a node based binary tree data structure that has the following properties: a. The left subtree of a node contains only nodes with keys less than that of the node’s key. b. Same with the right subtree. c. The left and right subtrees must also be binary search trees. d. There must be no duplicate nodes.
AVL Trees
AVL Balance condition:
Left and right subtrees have equal heights differing by at most 1.
Right subtrees have greater values than parent.
Left subtrees have lesser values than parent.
Single Rotation: Rotate between x and child
Double Rotation: 1. Rotate between x’s child and grandchild 2. Rotate between x and x’s new child
Heaps:
Heap of dogs. All the big dogs go to the bottom. You don’t want the small dogs to die.
For every non-root node x, the value in the parent of x is less than or equal to the value in x.
Null Path: The path length of the given node to the nearest descendant null node of the binary tree
Binary Min Heap is a complete tree.
DisjointSets
Union/Find Equivalence Equations a. Reflexive - R(a, a) for all a in s b. Symmetric - R(a, b) -> R(b, a) c. Transitive - R(a, b) -> R(a, c)
Path Compression- Every Node on the path from x to the root has its parents changed to the root.
Hashing
Open Addressing:
a. Linear Probing H(x, i) = (H(x) + i) % n
b. Quadratic Probing H(i) = (h(k) + i^2) % T
c. Double Hashing
H(i, k) = (h1(k) + ih2(k)) % T
Suggested Load Factor = Lambda = 1/2
Load Factor = The ratio of the number of records to the number of addresses within a data structure.
Graphs
DAG - A directed graph with no cycles.
Directed Graph: Graph with edges that have