Skip lists Flashcards

1
Q

Describe skip lists.

A

Skip lists have some variable MAX_LEVELS. We create a dummy node with this many levels.

For each element we insert, we select a random height between [1,MAX_LEVELS], and connect all the adjacent pointers on the same levels to it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do search a skip tree?

A

Start at the dummy node’s highest level. Look at the size of the element pointed to.

  • If lower, continue to that node and look at its highest level, then repeat this step.
  • If it’s higher, stay at the current node, go down one level and repeat the this step.

At some point, you’ll either:

  • reach the lowest level and it’s NULL (Eg. this is the highest element)
  • find the element’s position.
  • Find the position where the element would go, but realize the element is not there.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe deletion from a skip list.

A

1) Find the element.
2) Connect pointers to it to whatever it’s pointing to at that level.
3) Delete the element object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe inserting an element into a skip list.

A

1) Search for where the element would go.
2) Connect the parent elements to it.
3) Connect it to its children elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly