Gullu - Skip Lists Flashcards

1
Q

Skip Lists

A

Probabilistic Data Structure. Based on linked lists but fixing no random access problem.

In expectation, the skip list performance is O(log2n). Not as strong as a normal bound but good certainty

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

Overview of search in skip list

A
  • Let L = Topmost list
  • Move right until we find the value or a greater value than we are looking for
  • If value is greater, move to lower list and continue traversing there.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Maximum steps of 2 lists L1 and L2

A
  • Worst Case: Go through L1, Go down to L2 and go through L1/L2 steps, in total we have L1+L2/L1 steps
  • L2 is n = number of elements in data structure.
  • To minimise this we can choose the size of L1 since n is not a choice
  • This formula can be smaller: L1+n/L1 either when L1 is smaller or larger, we need balance. L1 = sqrt(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Maintain Ratio in Skip List

A

Use coin toss 50/50 to promote elements. Keeps time O(log2n)

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

First element in list (coin toss)

A

Given a value of negative infinity so it starts from the top and list always has a point to start from

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

Deletion

A

Trivial. If you want to delete something just find it and remove it

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

Theorem Skip List

A

With high probability, every search element in a n element skip list costs O(log2n).

If we have a constant c then no matter what c is; c*O(log2n) is still O(log2n)

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

WHP

A

An event occurs whp if for any number a>=1, the event occurs with a probability at least 1-O(1/n^a)

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

Search Backwards

A
  • Start from result
  • If we move up we got heads, if not we move left meaning tails
  • We finish at top left negative infinity
  • Think of any search string as “HTTHHTTHTHTTTH”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Statistics

A

Recall that object notation (n choose r) denotes number of ways we can choose r objects from a set containing n distinct elements. Also choose r = n!/r!(n-r)!
So if we flip a coin 4 times, in how many ways can we get 1 heads = HTTT, THTT, TTHT, TTTH.

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

Important Info

A
  • Search is performed from top left to bottom right
  • Can visualize search in reverse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Indexable Skip Lists

A

Skip Lists do insertions and deletions in O(log2n) time but traversals still take O(n) time, this can be fixed by storing the width of a link for every link. This way we can get O(log2n) time performance to look up an index.

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