ArticleslgStudy

computer science

Skip list

Skip list is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Skip list rather than just read about it. In short: In computer science, a skip list (or skiplist) is a probabilistic data structure that allows O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for search as well as O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for insertion within an ordered sequence of n {\displaystyle n} elements. Thus it can get the best features of a sorted array (for searching) while maintaining…

Skip list — main illustration
Skip list — illustration

Key takeaways

  • Skip list belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Skip list to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Skip list from memory before moving on to harder problems.

Reference excerpt

In computer science, a skip list (or skiplist) is a probabilistic data structure that allows O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for search as well as O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for insertion within an ordered sequence of n {\displaystyle n} elements. Thus it can get the best features of a sorted array (for searching) while maintaining a linked list-like structure that allows insertion, which is not possible with a static array. Fast search is made possible by maintaining a linked hierarchy of subsequences, with each successive subsequence skipping over fewer elements than the previous one (see the picture below). Searching starts in the sparsest subsequence until two consecutive elements have been found, one smaller and one larger than or equal to the element searched for. Via the linked hierarchy, these two elements link to elements of the next sparsest subsequence, where searching is continued until finally searching in the full sequence. The elements that are skipped over may be chosen probabilistically or deterministically, with the former being more common.

Description

A skip list is built in layers. The bottom layer 1 {\displaystyle 1} is an ordinary ordered linked list. Each higher layer acts as an "express lane" for the lists below, where an element in layer i {\displaystyle i} appears in layer i + 1 {\displaystyle i+1} with some fixed probability p {\displaystyle p} (two commonly used values for p {\displaystyle p} are 1 / 2 {\displaystyle 1/2} or 1 / 4 {\displaystyle 1/4} ). On average, each element appears in 1 / ( 1 − p ) {\displaystyle 1/(1-p)} lists, and the tallest element (usually a special head element at the front of the skip list) appears in all the lists. The skip list contains log 1 / p ⁡ n {\displaystyle \log _{1/p}n\,} (i.e. logarithm base 1 / p {\displaystyle 1/p} of n {\displaystyle n} ) lists. A search for a target element begins at the head element in the top list, and proceeds horizontally until the current element is greater than or equal to the target. If the current element is equal to the target, it has been found. If the current element is greater than the target, or the search reaches the end of the linked list, the procedure is repeated after returning to the previous element and dropping down vertically to the next lower list. The expected number of steps in each linked list is at most 1 / p {\displaystyle 1/p} , which can be seen by tracing the search path backwards from the target until reaching an element that appears in the next higher list or reaching the beginning of the current list. Therefore, the total expected cost of a search is 1 p log 1 / p ⁡ n {\displaystyle {\tfrac {1}{p}}\log _{1/p}n} which is O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)\,} , when p {\displaystyle p} is a constant. By choosing different values of p {\displaystyle p} , it is possible to trade search costs against storage costs. For example, the value p = 1 / e {\displaystyle p=1/e} minimizes the average search time of skip lists, whereas the value p = 1 / 2 {\displaystyle p=1/2} simplifies their implementation.

Implementation details

The elements used for a skip list can contain more than one pointer since they can participate in more than one list. Insertions and deletions are implemented much like the corresponding linked-list operations, except that "tall" elements must be inserted into or deleted from more than one linked list.

O ( n ) {\displaystyle {\mathcal {O}}(n)} operations, which force us to visit every node in ascending order (such as printing the entire list), provide the opportunity to perform a behind-the-scenes derandomization of the level structure of the skip-list in an optimal way, bringing the skip list to O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} search time. (Choose the level of the i'th finite node to be 1 plus the number of times it is possible to repeatedly divide i by 2 before it becomes odd. Also, i=0 for the negative infinity header as there is the usual special case of choosing the highest possible level for negative and/or positive infinite nodes.) However this also allows someone to know where all of the higher-than-level 1 nodes are and delete them. Alternatively, the level structure could be made quasi-random in the following way:

… excerpt ends here. Continue reading the full article.

Illustrations

Skip list: Inserting elements into a skip list
Inserting elements into a skip list

Worked examples

Example 1 — a first encounter with Skip list

Start with the simplest possible case. Write down what Skip list claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Skip list before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Skip list ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Skip list

In research
Skip list appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Skip list in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Skip list is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer-related introductions in 1989, Linked lists, Probabilistic data structures, so understanding it makes those chapters shorter.
In everyday life
Look for Skip list outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Skip list in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Skip list means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Skip list out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Skip list in simple terms?

In computer science, a skip list (or skiplist) is a probabilistic data structure that allows O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for search as well as O ( log ⁡ n ) {\displaystyle {\mathcal {O}}(\log n)} average complexity for insertion within an ordered sequence…

Why does Skip list matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Skip list?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Skip list.

Tags

  • Computer-related introductions in 1989
  • Linked lists
  • Probabilistic data structures

Keep exploring