Skip list
Ref: https://en.wikipedia.org/wiki/Skip_list
Skip list
- Bulit in layers.
- Bottom layer: ordered linked list.
- An element in layer \(i\) appears in layer \(i+1\) with probability \(p\).
- Express lane: 快车道
- Search process: top head \(\rightarrow\) go right \(\rightarrow\) if not found \(\rightarrow\) go down \(\rightarrow\) \(\cdots\)
- Indexable skiplist: \(O(\log n)\) look-up of the \(i\)th item.
1 10 o---> o---------------------------------------------------------> o Top level 1 | 3 2 5 o---> o---------------> o---------> o---------------------------> o Level 3 1 | 2 1 | 2 | 3 2 o---> o---------> o---> o---------> o---------------> o---------> o Level 2 1 | 1 1 | 1 | 1 1 | 1 1 1 | 1 1 o---> o---> o---> o---> o---> o---> o---> o---> o---> o---> o---> o Bottom level Head 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th NIL Node Node Node Node Node Node Node Node Node Node