Free
Search and talk to your own books.
Get AskLatte freeSee your book's real images, tables, code and math in your answer. Click any part to open its exact source on the page.A live tutor that explains and draws on your own books or a whiteboard. Powered by leading AI models for voice, reasoning and pen drawing.
Free plan. No credit card needed.p.103 has the node layout, Figure 4.2 and the struct Node code. p.182 compares the expected search paths: 2 log n + O(1) in a skiplist, 2 ln n + O(1) ≈ 1.386 log n + O(1) in a Treap. The arXiv benchmark agrees: treap queries took 234 s against 360 s for the skip list. Show the figure, the code and the formula from the book, then the web result.
A skiplist node holds one value and an array, next, of pointers, so the data, x, in a node is stored only once, even though x may appear in several lists. p.103
SkiplistSSet
struct Node {
T x;
int height; // length of next
Node *next[];
};The expected search path is in a Treap and in a skiplist, so the search paths in a Treap are considerably shorter. p.182
On the web, a 2026 benchmark agrees: treap queries took 234 s against 360 s for a skip list, which has "more nodes traversed on average". arxiv.org
Figure 4.2: The search path for the node containing 4 in a skiplist.
as consisting of a data value, x, and an array, next, of pointers, where u.next[i] points to u’s successor in the list Li. In this way, the data, x, in a node is stored only once, even though x may appear in several lists.
struct Node { T x; int height; // length of next Node *next[]; };
The next two sections of this chapter discuss two different applications of skiplists. In each of these applications, L0 stores the main structure (a list of elements or a sorted set of elements). The primary difference between these structures is in how a search path is navigated; in particular, they differ in how they decide if a search path should go down into Lr−1 or go right within Lr.
4.2 SkiplistSSet: An Efficient SSet
A SkiplistSSet uses a skiplist structure to implement the SSet interface. When used in this way, the list L0 stores the elements of the SSet in sorted order. The find(x) method works by following the search path for the smallest value y such that y ≥ x:
Node* findPredNode(T x) {
89
It is worth comparing the Treap data structure to the SkiplistSSet data structure. Both implement the SSet operations in O(log n) expected time per operation. In both data structures, add(x) and remove(x) involve a search and then a constant number of pointer changes (see Exercise 7.5 below). Thus, for both these structures, the expected length of the search path is the critical value in assessing their performance. In a SkiplistSSet, the expected length of a search path is
In a Treap, the expected length of a search path is
Thus, the search paths in a Treap are considerably shorter and this translates into noticeably faster operations on Treaps than Skiplists. Exercise 4.7 in Chapter 4 shows how the expected length of the search path in a Skiplist can be reduced to
by using biased coin tosses. Even with this optimization, the expected length of search paths in a SkiplistSSet is noticeably longer than in a Treap.
7.3 Discussion and Exercises
Random binary search trees have been studied extensively. Devroye [19] gives a proof of Lemma 7.1 and related results. There are much stronger results in the literature as well, the most impressive of which is due to Reed [62], who shows that the expected height of a random binary search tree is
where is the unique solution on the interval of the equation and . Furthermore, the variance of the height is constant.
168
Introducing Latte
Talk to Latte like a real tutor. With a pen, it explains your books right on the page, even inside images, and breaks down any answer on a whiteboard. It’s a live conversation: interrupt any time, in your own language. Powered by the leading AI models.
No credit card.
Ask about any passage, graph or equation, right from the page you’re reading.
Latte sketches on your page or a whiteboard while it explains.
Follow up, go deeper, or ask for it a different way.
Every source is a page
Click a citation and land on the exact table, image, code or math that informed the answer.






Works with ChatGPT, Claude and Perplexity
Connect your AskLatte library to ChatGPT, Claude or Perplexity, and they can search your books and answer from them.
Connect via MCP
Pricing
Search and talk to your own books.
Get AskLatte freeFor deep research across your books and the web.