SkipList Flashcards
1
Q
describe the insert method of the skiplist in pseudo code
A
p= skipsearch(k) q = insertafterabove(p, null, (k,v)) e = q.element()
2
Q
describe in words the insertion of a skiplist
A
insert(x,o)
- using a randomized algorithm
- repeatedly toss a coin until we get a tail, using I to denote the number of time heads was obtained
- if I >= h, add on to the skiplists until h = i+1
- search for the key x and keep track of the position containing largest key less than x in each list going up till Si
- for j = 0,1,2,3, …,i insert (x,o) into S till Sj after pj
3
Q
describe in words the removal method
A
to remove an entry x
- search for x in the list an find positions p1, …, pj
- Where position pj is in the list
- remove p0, …, pi in list S0, …, Si
- remove all list but one containing the 2 special keys
4
Q
describe the quad node
A
type of node storing:
element, above, below, prev and next
used to implement a skip list
5
Q
What is the probability of getting i consecutive heads when flipping a coin?
A
1/2^i
6
Q
Probable size of a skiplist?
A
n/2^i
7
Q
expected space usage for a skiplist?
A
O(n)
8
Q
What is the height of a skiplist?
A
O(log n)
9
Q
search, insertion, and deletion runtime?
A
O(log n)