Skip List: Insertion and Deletion Algorithms, Lecture notes of Data Structures and Algorithms

The process of inserting and deleting keys in a skip list. A skip list is a probabilistic data structure that allows fast search within an ordered sequence of elements. The algorithm starts by initializing the skip list with a header node and then inserts or deletes keys by updating the pointers of the nodes at each level. The random depth of the node to be inserted or deleted determines the number of levels that need to be adjusted.

Typology: Lecture notes

2020/2021

Uploaded on 01/02/2022

guna_shekar
guna_shekar 🇮🇳

4 documents

1 / 56

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38

Partial preview of the text

Download Skip List: Insertion and Deletion Algorithms and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

  • (^) The skip list is initialized with a header node of level 0, whose forward pointer is set to null.
  • (^) The top item shows the value associated with the skip list node. The head node is special so has the value "Hd".
  • (^) Starting from level 0 of the head, we look for the first node whose pointer points to the largest key that is less than or equal to key:10 that we want to insert, and save it into a temporary update array at index level.
  • (^) If no such key exists because the pointer is null, then update array will contain the last node at that level.
  • (^) We save this highlighted node into our updated array since it will point to our new key: 10 if their height matches.
  • (^) The update array actually contains a pointer to a node but we display the value of the node it is pointing to. To continue the process, we reduce level by one or stop if there are no more levels.
  • (^) All of the pointers are now updated.
  • (^) Insert value 30, assuming randomLevel returns 1.
  • (^) The random depth of the node to be inserted is 1, so we must adjust the depth of the header node before inserting.
  • (^) Starting from level 1 of the head, we look for the first node whose pointer points to the largest key that is less than or equal to key:30 that we want to insert, and save it into a temporary update array at index level.
  • (^) If no such key exists because the pointer is null, then update array will contain the last node at that level.
  • (^) We compare 30 to the next record 10. If it is less, we move forward, else we save this value.
  • (^) We save this highlighted node into our updated array since it will point to our new key: 30 if their height matches.
  • (^) The update array actually contains a pointer to a node but we display the value of the node it is pointing to.
  • (^) To continue the process, we reduce level by one or stop if there are no more levels.
  • (^) All of the pointers are now updated.
  • (^) Insert value 20, assuming randomLevel returns 2.
  • (^) Starting from level 2 of the head, we look for the first node whose pointer points to the largest key that is less than or equal to key:20 that we want to insert, and save it into a temporary update array at index level.
  • (^) If no such key exists because the pointer is null, then update array will contain the last node at that level.
  • (^) We save this highlighted node into our updated array since it will point to our new key: 20 if their height matches.
  • (^) The update array actually contains a pointer to a node but we display the value of the node it is pointing to.
  • (^) To continue the process, we reduce level by one or stop if there are no more levels.