Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add Skip List Implementation #22

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A skip list is a data structure that is similar to a linked list but with an added feature of hierarchical levels that allow for faster search and insertion operations. Each node in a skip list contains an element of data and a set of pointers that link to other nodes at different levels. These pointers allow the data to be "skipped" over, making it possible to quickly find a specific element in the list.

From a more technical perspective, a skip list is a probabilistic data structure that is used to implement a sorted dictionary. It is a linked list with multiple levels, each level represents a level of "skipping" and each node in the list contains elements along with a set of forward pointers to other nodes in the list. The highest level contains all the elements in the list and the lower levels have subsets of the elements, where each element has a probability of appearing in the lower levels. Each level of a skip list is a regular singly linked list. The search and insertion operations are done from the highest level and move down the levels until the appropriate element is found or the bottom level is reached. The expected time complexity of search, insertion and deletion operations is O(log n) which is faster than the O(n) time complexity of a typical singly linked list.