CSE 373 Lecture 14: Midterm Review Today's Topics:: Hashing: Applications
CSE 373 Lecture 14: Midterm Review Today's Topics:: Hashing: Applications
✦ Components: TableSize (prime), hash function, collision strategy ✦ Think of O(f(N)) as “less than or equal to” f(N) ! Upper bound
| k +1|
for large N and k ≠ -1 { if (num == 0) return 0;
else return v[num-1] + sum(v,num-1); }
∑ A = i
A −1
∑2
i =0
i
=2 N +1
−1 = 2*constant + T(num-2) =…= num*constant + constant
= Θ(num)
i =0
✦ AVL tree: What makes a BST an AVL tree? ✦ All leaf nodes at same height
➭ Balanced due to restriction on heights of left/right subtrees
➭ Upper bound on height of AVL tree of N nodes ✦ Know how to do Find, Insert, and Delete in example B-trees
➭ Worst case run time for operations ➭ Insert may cause leaf node to overflow and split, causing parent to
➭ Know what happens when you do Inserts into an AVL tree split etc.
➭ Re-balancing tree using Single or Double rotation ➭ Deletion may cause leaf to become less than half full, causing a
merge with sibling, which may cause parent to merge etc.
✦ Splay trees: No explicit balance condition but accessing an
item causes splaying (rotations); item moves to root ✦ What is the depth of an N-node B-tree?
➭ Find: Run time is O(depth*log M) = O(log M/2 N*log M) = O(log N)
➭ Amortized/worst case running time for operations
➭ Know what happens when you do Find/Insert/Delete ➭ Insert and Delete: Run time is O(depth*M) = O((M/log M)*log N)