# Data structures Tree Search trees AVL Red

```AVL
Red-black
Search trees
avg. O(log N), worst O(N)
B-tree
DAG
insert(x, p)
while inngrad = 0; print; process edges
Priority heap
Toplogicial sort
deleteMin()
O(V E) med Queue
Complete binary tree
Unidirected node-node paths
Svakt CC
Bidirected node-node paths
Sterkt CC
Impl. som array
Node &gt;= parent
Tree
Graf
Binary heap
Array
single-source SPF for DAG
idx*2 left, idx*2+1 right, idx/2 parent
up/down insert/delete
Dijkstra
percolate
O(|E| + V log V)
O(log N)
MST
Prim
heap property: If A is a parent node of B then the
key of node A is ordered with respect to the key
of node B with the same ordering applying across
the heap. Either the keys of parent nodes are
always greater than or equal to those of the
children and the highest key is in the root node
(this kind of heap is called max heap) or the keys
of parent nodes are less than or equal to those of
the children and the lowest key is in the root
node (min heap)
MST
Kruskal
O(|E| log |V|)
shift[needle[i]] = len - i - 1
O(1) lookup, O(kn) space, k=alphabet
O(n) lookup/space
Hvis n&aring;l[i − 1] er en mismatch og n&aring;l inneholder
en annen kopi av n&aring;l[i..n] som ikke har tegnet
n&aring;l[i − 1] som prefiks, flytt n&aring;l slik at kopien
matcher substrengen som allerede var matchet
av n&aring;l[i..n]
log_M(N) height
Data structures
Boyer-Moore
Strings
Hash
&Aring;pen
List on duplicate
Lukket
Next on duplicate
Utvidbar
good-suffix-shift
Sorting
fiskekake/ke = 4. _ = 1
Qsort
Diskblokker, 2 niv&aring;
Median-of-three
In the long term, the total time taken for adding
m items to the array is O(m), and so the
amortised time (i.e. time per insertion) is O(1
flytt n&aring;l minst mulig slik at et suffiks av t matcher
et prefiks av n&aring;l
log(100) = 7 bits needed
An algorithm is O(log N) if it takes constant time,
O(1), to cut the problem size by a fraction.
Rec path from root; 0 left, 1 right; char in leaves
Trie
program
Prefix code; unambigious
1. Merge single-trees/w lowest weight
Compression
Algo
2. Merge any trees with lowest weight: repeat
algorithm
Huffman
finiteness, definiteness, input, output,
effectiveness.
computational method: algorithm - finiteness.
O(C log C) with priqueue; O(C^2) when list-impl.
Two-pass/offline algo due to frequency count
an expression of a computational method written
in a computer language
Euclid GCD
online
balance