How do Skip Lists work, and in what scenarios are they preferred over other data structures?
Instruction: Describe the architecture of Skip Lists and discuss their performance in comparison to other data structures for various operations.
Updated
Official answer
A skip list keeps ordered values in a base linked list plus higher levels of forward pointers. Randomly chosen node heights create sparse shortcuts. Search moves forward at a level until another step would pass the target, then descends.
Insertion records the predecessor at each relevant level, chooses a height and rewires those links. Deletion finds and bypasses the node's links. With suitable independent geometric promotion, search and updates take expected O(log n) time and expected storage is O(n). A poor random realization can degrade search to linear time; this is different from a balanced tree's deterministic logarithmic height guarantee.
Ordered traversal and range queries are natural: locate the start, then follow base-level links, paying for the returned entries. Choose a promotion probability and practical height policy, and define duplicate-key semantics.
Skip lists can be attractive when ordered operations and implementation tradeoffs fit the workload, but are not universally simpler, smaller or faster. Pointer overhead and locality matter. Concurrent versions require their own synchronization and memory-reclamation design; randomized structure alone does not make updates thread-safe. Benchmark against the actual balanced-tree or array alternative.