Skip to content

Commit a0c3aa2

Browse files
committed
created Skip List README file
1 parent 4c186ef commit a0c3aa2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

modules/SkipList/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Skip List
2+
3+
[Skip List](https://en.wikipedia.org/wiki/Skip_list) is a data structure that provides an efficient alternative to balanced binary search trees for maintaining a sorted list of elements. It is a probabilistic data structure that uses multiple linked lists with different skip probabilities to achieve logarithmic average time complexity for search, insertion, and deletion operations.
4+
5+
6+
## Features
7+
- Efficient search, insertion, and deletion in average logarithmic time complexity (O(log n)).
8+
- Simple and easy to implement compared to balanced binary search trees.
9+
- No need for rotations and rebalancing during insertions and deletions, making it easier to maintain.
10+
- Scalable and adaptable for use cases where dynamic resizing is needed.
11+
12+
### Time complexity of the implemented functions
13+
14+
<img align="right" width=480 alt="Skip List picture" src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Skip_list.svg/800px-Skip_list.svg.png">
15+
16+
| Function | Time Complexity |
17+
|--------------------------------|-------------------|
18+
| `skiplist_initialize` | O(1) |
19+
| `skiplist_get_size` | O(1) |
20+
| `link_get_value` | O(1) |
21+
| `skiplist_insert` | O(log n) |
22+
| `skiplist_search` | O(log n) |
23+
| `skiplist_delete` | O(log n) |
24+
| `skiplist_print` | O(n) |
25+
| `skiplist_merge` | O(n log n) |
26+
| `skiplist_destroy` | O(n) |
27+
28+
29+
30+
## Implementation Details
31+
The Skip List is composed of multiple levels, with each level representing a separate linked list. The bottom level is a standard linked list containing all the elements in sorted order. Higher levels consist of a subset of the elements from the lower level, forming shortcuts or "skips" between nodes.
32+
33+
Each node in a level contains a forward pointer that connects to the next node in the same level. Additionally, it may have an additional forward pointer that connects to a node in the next higher level. The higher-level nodes are skipped with a certain probability, effectively reducing the search space and improving the average time complexity.
34+
35+
The Skip List maintains a tower of linked lists, with the bottom level having all the elements and the top level containing just one element, which is the largest element in the list. The top-level elements act as sentinels that prevent unnecessary boundary checks.
36+
37+
## Limitations
38+
- Skip List requires additional memory compared to simple linked lists.
39+
- While Skip List provides efficient average-case time complexity, its worst-case time complexity for search, insert, and delete operations is O(n).
40+
- Skip List is not well-suited for applications where strict determinism and worst-case performance guarantees are required.
41+
42+
## Readings
43+
The following paper should be very useful: https://drum.lib.umd.edu/handle/1903/544

0 commit comments

Comments
 (0)