SkiplistSSet: An Efficient SSet
Explore how SkiplistSSet implements the SSet interface using a skiplist to maintain elements in sorted order. Understand the efficient O(log n) expected runtime of add, remove, and find operations. Learn algorithms for node height selection, insertion using a stack to track search paths, and removal techniques. Gain practical insight through code examples and test cases that verify operation correctness and performance.
We'll cover the following...
A SkiplistSSet uses a skiplist structure to implement the SSet interface. When used in this way, the list stores the elements of the SSet in sorted order.
The find() method
The find(x) method works by following the search path for the smallest value such that :
Following the search path for is easy: when situated at some node, u, in , we look right to u.next[r].x. If x > u.next[r].x, then we take a step to the right in ...