Ask
with the leading AI models

See 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.
AskLibraryConnectSkills
Pro · 2.2 GBE
New chat
Good morning, Emma
Skiplist Search and Treap Speed· 1 question
Search my books and the web: how does a skiplist search work, and is a Treap faster?
Thinking
Searching the whole library
Thinking
skiplist search pathsearching…
treap vs skip list benchmarksearching…
Reading 1 web page
Thinking
Fast and Theoretically-Efficient Batch-Parallel Link-Cut Trees, Euler Tour Trees, and Treapsreading…
treap expected search path lengthsearching…
Thinking

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

L0L1L2L3L4L50123456sentinel
Figure 4.2: The search path for the node containing 4 in a skiplist.
                        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

Searching… · 0s
Ask anything...Type @ to mention books and folders
SearchBalanced
Open Data Structures C++
Open Data Structures C++
←103/ 336→LatteBETA−125%+
SkiplistSSet: An Efficient SSet§4.2
L0L1L2L3L4L50123456sentinel

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.

SkiplistSSet
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:

SkiplistSSet
Node* findPredNode(T x) {

89

§7.3Random Binary Search Trees

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

Find source
  • SearchFast, focused search
  • Deep searchDeeper search across your library and the web
  • Short
  • Balanced
  • Detailed
  • Books & FilesSearch your Books and files
  • Book Notes & HighlightsSearch your highlights, comments and sticky notes
  • Web searchSearch the public web
  • Community searchReddit, Hacker News, Stack Overflow, GitHub
  • Auto
  • GPT-6 LunaNew
  • Claude Haiku 5.5
  • DeepSeek V4.1 Flash
  • Gemini 3.5 Flash-Lite
  • Claude Sonnet 5.5Pro
  • GPT-6.1 TerraPro
  • GPT-6.1 SolPro
  • Gemini 3.1 ProPro
  • DeepSeek V4 ProPro
  • Kimi K3.1 ProPro
  • Claude Opus 5.5Max
  • Gemini 4 ArgonMax
AskLibrary

Introducing Latte

Your Own Personal AI Tutor

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.

Talk to Latte free

No credit card.

“Explain this image to me.”
Ask the moment you’re stuck

Ask about any passage, graph or equation, right from the page you’re reading.

See the idea drawn out

Latte sketches on your page or a whiteboard while it explains.

Keep asking until it clicks

Follow up, go deeper, or ask for it a different way.

Every source is a page

Check any answer in one click.

Click a citation and land on the exact table, image, code or math that informed the answer.

A sentence's citation in an answer and the book page with that sentence highlighted

Works with ChatGPT, Claude and Perplexity

Keep using the AI tools you already know.

Connect your AskLatte library to ChatGPT, Claude or Perplexity, and they can search your books and answer from them.

ChatGPTClaudePerplexity

Connect via MCP

Pricing

Start free.
Go Pro when you need more.

Pro

For deep research across your books and the web.

  • Your data is never sold or used to train our models
  • Encrypted in transit
  • Stored and hosted in the US (AWS)
  • Delete your data anytime