0% found this document useful (0 votes)
171 views6 pages

Skip List: ADS Skip List Iii I.T - I Sem

Skip lists are a variant of linked lists that allow for faster search, insertion, and deletion on average. A skip list contains nodes connected in a series, with each node containing a key-value pair and references to nodes further along in the list. The references are assigned randomly at different levels, allowing the search to skip over nodes quickly. Searching begins at the highest level and moves forward, dropping down a level when it encounters a higher key. Insertion and deletion first locate the position through search, then add or remove nodes while updating references. The expected time complexity of operations on skip lists is O(log n), faster than standard linked lists.

Uploaded by

RaviKumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views6 pages

Skip List: ADS Skip List Iii I.T - I Sem

Skip lists are a variant of linked lists that allow for faster search, insertion, and deletion on average. A skip list contains nodes connected in a series, with each node containing a key-value pair and references to nodes further along in the list. The references are assigned randomly at different levels, allowing the search to skip over nodes quickly. Searching begins at the highest level and moves forward, dropping down a level when it encounters a higher key. Insertion and deletion first locate the position through search, then add or remove nodes while updating references. The expected time complexity of operations on skip lists is O(log n), faster than standard linked lists.

Uploaded by

RaviKumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ADS

SKIP LIST

III I.T I SEM

Skip List Skip list is a variant list for the linked list. Skip lists are made up of a series of nodes connected one after the other. Each node contains a key and value pair as well as one or more references or pointers to nodes further along in the list. The number of references each node contains is determined randomly. This gives skip lists their probabilistic nature, and the number of references a node contains is called its node level. There are two special nodes in the skip list one is head node which is the starting node of the list which consists of every level of pointer and tail node is the last node of the list. The skip list is an efficient implementation of dictionary using sorted chain. This is because in skip list each node consists of forward references of more than one node at a time. A skip list S for a map M consists of a series of lists { So , S1 , .. . , Sh,}. Each list Si stores a subset of the entries of M sorted by increasing order of keys. In addition, the lists in S satisfy the following: List So which is in level 0 contains every entry of the map M List S1 which is in level 1 includes every second element of S0 List. List S2 which is in level 2 includes every fourth element of S1 list. Similarly List Si which is in level I includes every 2I th element of its previous Si-1 list An element is a level i element iff it is in the chains from levels 0 through i

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 1

ADS

SKIP LIST

III I.T I SEM

Search Operation Searching for a key with in a skip list begins at the header from the highest level of skip list and moving forward in the list comparing node keys to the key_val. If the node key is less than the key_val, the search continues moving forward at the same level. If the node key is equal to or greater than the key_val, the search drops down one level in the same node and continues forward. This process continues until the desired key_val has been found if it is present in the skip list. If it is not, the search will either continue to the end of the list or until the first key with a value greater than the search key is found.

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 2

ADS

SKIP LIST

III I.T I SEM

Insertion into skip list There are two tasks that should be done before insertion operation 1. Before insertion of any new node, the place for this new node in the skip list is searched. Hence before any insertion to take place the search routine executes. The update[ ] array in the search routine is used to keep track of the references to the

nodes where the search drops down one level. update[i] contains a pointer to the rightmost node of level i or higher that is to the left of the location of the insertion. If an insertion generates a node with a level greater than the previous maximum level of the list, we update the maximum level of the list and initialize the appropriate portions of the update vector.

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 3

ADS

SKIP LIST

III I.T I SEM

2. The level for the new node is retrieved by the routine randomLevel( ). Then a new node is actually created and inserted in the skip list in the specific level. Determining the level of new node When a new element is inserted into the list, a node with a random level is inserted to represent the element. Random levels are generated on the basis of probabilistic approach with a simple pattern: 50% are level 1, 25% are level 2, 12.5% are level 3 and so on. To get away from these conventions, consider fraction p of the nodes with level i pointers also have level i+1 pointers where p=1/2. Levels are generated without reference to the number of elements in the list.

Algorithm for insertion

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 4

ADS

SKIP LIST

III I.T I SEM

For example

Deletion from skip list First of all, the deletion makes use of search algorithm and searches the node that is to be deleted. If the key to be deleted is found, the node containing the key is removed. While searching, a vector update[ ] is maintained so that when the search is complete update[i] contains a pointer to the rightmost node of level i or higher that is to the left of the location of the deletion. After each deletion, we check if we have deleted the maximum element of the list and if so, decrease the maximum level of the list. Algorithm for Deletion

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 5

ADS

SKIP LIST

III I.T I SEM

For example

Analysis of Skip List Operations The time required to execute the Search, Delete and Insert operations is dominated by the time required to search for the appropriate element. For the Insert and Delete operations, there is an additional cost proportional to the level of the node being inserted or deleted. The time required to find an element is proportional to the length of the search path, which is determined by the pattern in which elements with different levels appear as we traverse the list. Despite the poor worst case performance, skip list are a valuable representation method, as the expected complexity of methods insert, delete and search is O(log n).

S.RAVI KUMAR, DEPT.OF.IT, SVECW

Page 6

You might also like