Javatpoint Logo
Javatpoint Logo

Skip list in Data structure

What is a skip list?

A skip list is a probabilistic data structure. The skip list is used to store a sorted list of elements or data with a linked list. It allows the process of the elements or data to view efficiently. In one single step, it skips several elements of the entire list, which is why it is known as a skip list.

The skip list is an extended version of the linked list. It allows the user to search, remove, and insert the element very quickly. It consists of a base list that includes a set of elements which maintains the link hierarchy of the subsequent elements.

Skip list structure

It is built in two layers: The lowest layer and Top layer.

The lowest layer of the skip list is a common sorted linked list, and the top layers of the skip list are like an "express line" where the elements are skipped.

Complexity table of the Skip list

S. No Complexity Average case Worst case
1. Access complexity O(logn) O(n)
2. Search complexity O(logn) O(n)
3. Delete complexity O(logn) O(n)
4. Insert complexity O(logn) O(n)
5. Space complexity - O(nlogn)

Working of the Skip list

Let's take an example to understand the working of the skip list. In this example, we have 14 nodes, such that these nodes are divided into two layers, as shown in the diagram.

The lower layer is a common line that links all nodes, and the top layer is an express line that links only the main nodes, as you can see in the diagram.

Suppose you want to find 47 in this example. You will start the search from the first node of the express line and continue running on the express line until you find a node that is equal a 47 or more than 47.

You can see in the example that 47 does not exist in the express line, so you search for a node of less than 47, which is 40. Now, you go to the normal line with the help of 40, and search the 47, as shown in the diagram.

Skip list in Data structure

Note: Once you find a node like this on the "express line", you go from this node to a "normal lane" using a pointer, and when you search for the node in the normal line.

Skip List Basic Operations

There are the following types of operations in the skip list.

  • Insertion operation: It is used to add a new node to a particular location in a specific situation.
  • Deletion operation: It is used to delete a node in a specific situation.
  • Search Operation: The search operation is used to search a particular node in a skip list.

Algorithm of the insertion operation

Algorithm of deletion operation

Algorithm of searching operation

Example 1: Create a skip list, we want to insert these following keys in the empty skip list.

  1. 6 with level 1.
  2. 29 with level 1.
  3. 22 with level 4.
  4. 9 with level 3.
  5. 17 with level 1.
  6. 4 with level 2.


Step 1: Insert 6 with level 1

Skip list in Data structure

Step 2: Insert 29 with level 1

Skip list in Data structure

Step 3: Insert 22 with level 4

Skip list in Data structure

Step 4: Insert 9 with level 3

Skip list in Data structure

Step 5: Insert 17 with level 1

Skip list in Data structure

Step 6: Insert 4 with level 2

Skip list in Data structure

Example 2: Consider this example where we want to search for key 17.

Skip list in Data structure


Skip list in Data structure

Advantages of the Skip list

  1. If you want to insert a new node in the skip list, then it will insert the node very fast because there are no rotations in the skip list.
  2. The skip list is simple to implement as compared to the hash table and the binary search tree.
  3. It is very simple to find a node in the list because it stores the nodes in sorted form.
  4. The skip list algorithm can be modified very easily in a more specific structure, such as indexable skip lists, trees, or priority queues.
  5. The skip list is a robust and reliable list.

Disadvantages of the Skip list

  1. It requires more memory than the balanced tree.
  2. Reverse searching is not allowed.
  3. The skip list searches the node much slower than the linked list.

Applications of the Skip list

  1. It is used in distributed applications, and it represents the pointers and system in the distributed applications.
  2. It is used to implement a dynamic elastic concurrent queue with low lock contention.
  3. It is also used with the QMap template class.
  4. The indexing of the skip list is used in running median problems.
  5. The skip list is used for the delta-encoding posting in the Lucene search.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA