Goal: Maintain an ordered set S supporting Search, Insert, and Delete.
next memory address).| Operation | Sorted List Cost |
|---|---|
Search(k) |
\Theta(n) |
Insert(x) |
\Theta(n) |
Delete(x) |
\Theta(n) |
How do we maintain a set of ordered elements supporting search, insertion, and deletion in O(\log n) time?
A skip list is a hierarchy of ordered linked lists.
next) and a down pointer (below) to the level underneath.A search hops horizontally on express lanes, dropping down when the next key exceeds target:
Search(k): Start at top-left sentinel. Walk right while \text{next} \le k; drop down to L_{i-1} when \text{next} > k. Repeat until found or reaching L_0.Insert(k): Run Search(k) to find position in L_0. Repeatedly flip a fair coin: if Heads, promote k to L_{i+1}; if Tails, stop.Delete(k): Search for k and unlink it from all levels where it appears via standard O(1) pointer rewiring.What is the expected maximum level of a skip list on n elements?
Trace the search path backwards from target key in L_0 up to the start:
Is the pointer overhead too large compared to balanced binary trees?
Q1: If coin flip probability is p = 1/4, what is the expected number of pointers per node?
Answer: 1/p = \mathbf{4} pointers per node on average.
Q2: Why is backward analysis preferred over forward analysis?
Answer: Forward paths depend on global structure, while backward steps form a simple, memoryless coin-flipping recurrence at each step.
Hash Tables & Universal Hashing — collision rates, pairwise independence, and universal hash families.
CS G526: Advanced Algorithms & ComplexityTulasimohan Molli