Skip List vs. Binary Search Tree
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
In the world of data structures, efficient searching, insertion, and deletion operations are crucial for performance optimization. Two data structures that are frequently discussed in this context are Skip Lists and Binary Search Trees (BSTs). Both are designed to maintain ordered data and allow for quick search operations, but they achieve these goals through distinct methodologies. This article delves into the nuances of Skip Lists and Binary Search Trees, exploring their implementations, advantages, and application scenarios.
Skip List
Overview
Skip Lists are probabilistic data structures that offer efficient search operations similar to balanced BSTs, with expected logarithmic performance. Invented by William Pugh in 1989, Skip Lists consist of multiple levels of linked lists. Each level is a subset of the one before it, allowing quick skip through large portions of data, hence the name.
Structure
A Skip List is composed of multiple layers:
- The bottom layer contains all the elements in sorted order.
- Each higher layer acts as an "express lane," skipping over several elements in the layer below.
The probability p is used to determine the number of levels a node spans, guiding the structure's balancing. Typically, p is set to 0.5.
Operations
- Search: Begin at the highest level, moving either forward or downward to find the target, with average time complexity .
- Insertion: Randomly choose levels for the new node using probability
p, then insert it from top to bottom. - Deletion: Remove the node from each level it appears, adjusting pointers accordingly.
Here is a simplified illustration of Skip List operations:
Binary Search Tree (BST)
Overview
A Binary Search Tree is a tree data structure where each node has at most two children, often referred to as the left and right child. The left subtree contains only nodes with values less than the parent node's value, and the right subtree only those with values greater than the parent node's value.
Structure
- Node: Each node contains a value, and pointers to its left and right child.
- Balanced vs. Unbalanced: In unbalanced BSTs, operations may degrade to linear time. Balanced trees like AVL or Red-Black Trees maintain performance at .
Operations
- Search: Traverse the tree from the root to the desired value, choosing left or right based on comparison, with an average time complexity of in balanced trees.
- Insertion: Insert nodes, maintaining the BST property.
- Deletion: Remove a node and re-link the tree, maintaining the order property. Removing nodes with two children is the most complex scenario.
Here's a BST example:
Comparative Analysis
Efficiency
Both Skip Lists and BSTs generally offer worst-case time complexity for insertions, deletions, and searches in balanced cases. However, Skip Lists employ randomization to achieve efficiency, while BSTs base their performance on structure.
Memory Usage
- Skip Lists: Generally consume more memory due to the need for multiple layers of pointers.
- BSTs: Require less memory, storing just two pointers per node.
Balance Maintenance
- Skip Lists: Use randomization to maintain balance at each insertion and deletion.
- BSTs: Require frequent rebalancing through rotations and other mechanisms, which may be complex, particularly in trees like AVL or Red-Black Trees.
Implementation Complexity
- Skip Lists: Somewhat simpler in terms of rebalancing, with the probabilistic approach.
- BSTs: Potentially more intricate due to explicit balancing requirements.
Suitability for Applications
- Skip Lists: Suitable for concurrent applications or where predictable performance is necessary without complex balancing logic.
- Binary Search Trees: Suitable for scenarios where memory usage is a concern and deterministic behavior is required.
Key Points Table
| Feature | Skip List | Binary Search Tree |
| Time Complexity | (average case) | (average case) if balanced |
| Space Complexity | O(n ) | O(n) |
| Insertion Best/Worst | O(1) / O(n) | O(log n) / O(n) |
| Deletion Best/Worst | O(1) / O(n) | O(log n) / O(n) |
| Balanced Nature | Probabilistic | Deterministic |
| Ease of Implementation | Moderately Complex | Potentially Complex (for balanced trees) |
| Memory Usage | Higher | Lower |
Conclusion
In summary, Skip Lists and Binary Search Trees represent different philosophies in designing data structures optimized for search, insertion, and deletion. Each has its pros and cons, making them applicable in different scenarios. Skip Lists provide a more flexible approach to balance at the expense of increased memory usage, whereas Binary Search Trees deliver a more memory-efficient solution with potential rebalancing overhead. Understanding the specific needs of your application is critical in choosing the appropriate data structure.
Related reading
- Skip lists, are they really performing as good as Pugh paper claim?
- Sklearn list of algorithms
- Slow Sums Algorithm
- Smallest n-bit integer c that has k 1-bits and is the sum of two n-bit integers that have g, h bits set to 1dynamic programming
- Slicing a dictionary
- Slow Performance with Apache Spark Gradient Boosted Tree training runs
- Smallest window substring that has both uppercase and corresponding lowercase characters
- Smart pagination algorithm that works with local data cache

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.