Linear
Tree-based
Sorting
Tree and graph exploration
diff
Cryptography
\[ 1 < \alpha(n) < \log n < n^\epsilon \] \[ n < n^2 < n^3 < \ldots < 2^n < 3^n < \ldots < 2^n \] \[ 2^n < 3^n < \ldots < 2^{2^n} < 2^{2^{2^n}} < \ldots < \mathsf{ackermann} \]
How often is tick
called?
for (int i = 1; i < n; i++) {
tick();
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < n; j++) {
tick();
}
}
for (int i = 1; i < n; i++) {
for (int j = 1; j < i; j++) {
tick();
}
}
for (int i = 1; i < n; i++) {
for (int j = n; j > 1; j = j/2) {
tick();
}
}
for (int i = 1; i < n; i++) {
for (int j = i; j > 1; j = j/2) {
tick();
}
}
An AVL tree is a BST satisfying the AVL condition: every node’s balance factor is 0, -1 or 1.
When nodes are added or deleted we may need to rebalance to maintain the AVL condition.
This is done using rotations.
Do the same! Just make sure to place the subtrees in such a way that the inorder traversal is unchanged.
RR case:
RL case: