14 SKIP LISTS Flashcards

1
Q

What is a skip list?

A

A sorted linked list with multiple pointers that allow jumping forward to elements further ahead during operations like search, insertion, or deletion.

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

Who proposed the concept of skip lists?

A

William Pugh

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

What is the main advantage of using skip lists over traditional linked lists?

A

They mitigate the need to scan through all elements, allowing for more efficient search, insertion, and deletion.

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

How do skip lists improve search efficiency?

A

By creating multiple layers of linked lists, allowing searches to start at higher levels with fewer nodes and take larger steps.

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

What is the structure of a skip list node?

A

Each node has a key, value, height, and an array of pointers to SkipListNodes.

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

Define the terms ‘top_level’ and ‘max_level’ in a skip list.

A

‘top_level’ represents the highest level currently in use; ‘max_level’ represents the highest allowable level.

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

What role does randomness play in skip lists?

A

Randomness is used to assign heights to nodes, which helps balance performance in average cases.

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

True or False: Skip lists are deterministic data structures.

A

False

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

What happens if all nodes in a skip list are at the same level?

A

The skip list devolves into a sorted linked list with additional memory overhead.

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

How is the height of a new node determined in a skip list?

A

By flipping a weighted coin and checking against a constant probability p until a number greater than p is obtained or the maximum height is reached.

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

What does the search process in a skip list involve?

A

Starting at the top-most level and iterating through nodes, dropping down levels as necessary until the target is found or the end is reached.

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

Fill in the blank: Skip lists allow for _______ steps across the list to skip unnecessary nodes.

A

large

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

What is a key disadvantage of deterministic data structures when faced with worst-case data?

A

They can become inefficient, such as a binary search tree becoming a sorted linked list if data is inserted in sorted order.

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

Describe the relationship between node height and the number of nodes at that level in a skip list.

A

Nodes of level L + 1 are less numerous than nodes at level L, promoting a good average case performance.

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

What metaphor is used to describe the process of searching in a skip list?

A

Passing messages between buildings by signaling with flashlights.

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

What is the termination condition for the search in a skip list?

A

The search terminates when trying to drop below the bottom level.

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

What happens during the search if the target key is not found?

A

The search returns null.

18
Q

Fill in the blank: Skip lists are _______ data structures.

A

randomized

19
Q

What is the expected outcome when using a good randomization strategy in skip lists?

A

It will often produce a reasonable structure and provide good average case performance.

20
Q

How do skip lists prevent consistently suboptimal choices?

A

By introducing randomness into the structural choices of the data.

21
Q

What analogy is used to describe the traversal in a skip list?

A

A squirrel navigating along a row of trees.

22
Q

What is the main purpose of using a probability p in skip lists?

A

To balance search efficiency with memory usage.

23
Q

How does William Pugh’s approach determine the height of a node in a skip list?

A

By flipping a weighted coin until a number greater than p is obtained or the maximum height is reached.

24
Q

What is the expected number of nodes at level L when using p = 0.5?

A

Approximately half the nodes at level L are expected to be promoted to level L + 1.

25
What happens when the parent in the candy analogy decides to say 'No more candy'?
The process of increasing the height of the node stops.
26
What is the initial step when adding nodes to a skip list?
Progress downward and to the right, looking for a place to insert the new node.
27
What data structure is used to track the last node at each level during insertion?
An array of SkipListNode pointers.
28
What is the purpose of the WHILE loops in the SkipListInsert function?
To search for the correct place to insert the new node.
29
What does the SkipListDelete function primarily do?
It searches for a target node and removes it from the skip list.
30
What is the worst-case performance of a skip list?
Linearly proportional to the number of nodes, similar to a standard linked list.
31
What is the expected time complexity for search, insertion, and deletion in a skip list?
Logarithmic in the number of entries.
32
True or False: Skip lists are a simpler alternative to balanced search trees.
True.
33
In what scenario does the performance of a skip list degrade to that of a linked list?
When every node in the list is the same height.
34
What are the benefits of using randomization in skip lists?
Robustness against bad data and simplicity in implementation.
35
Fill in the blank: The expected computational cost of common operations in skip lists is _______.
logarithmic in the size of the list.
36
What is the role of the dummy node in a skip list?
To store pointers to the beginning of the list.
37
What happens if the selected new level during insertion is greater than the current top level?
The list's top level is updated to the new level.
38
How do skip lists compare to binary search trees in terms of average performance?
They are on par with binary search trees.
39
What is the significance of the variable max_level in a skip list?
It caps a node's height to stay consistent with the preallocated array.
40
What does the last array track during the deletion process?
The last node at each level before the target node.
41
How does the structure of a skip list affect search efficiency?
Nodes are spaced evenly apart, allowing for logarithmic search behavior.