Search⌘ K
AI Features

SkiplistList: An Efficient Random-Access List

Explore the implementation of SkiplistList, a data structure that supports list operations like get, set, add, and remove in O(log n) expected time. Understand how edge lengths help navigate the skiplist efficiently and how elements are inserted and removed, allowing you to handle random access in lists effectively using skiplists.

A SkiplistList implements the List interface using a skiplist structure. In a SkiplistList, L0L_0 contains the elements of the list in the order in which they appear in the list. As in a SkiplistSSet, elements can be added, removed, and accessed in O(logn)O(\log n) time.

The length of an edge

For this to be possible, we need a way to follow the search path for the ithi^{th} element in L0L_0. The easiest way to do this is to define the notion of the length of an edge in some list, LrL_r. We define the length of every edge in L0L_0 as ...