cs126 skip lists

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/15

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

What is a skip list?

  • An ADT that is an implementation of a Map

  • Can be viewed as a 2D collection of positions arranged horizontally into levels and vertically into towers

2
New cards

Describe the structure of a skip list.

  • For a set S, its skip list is a series of lists

    S0, S1 , … , Sh such that:

    • Each list Si contains the special keys +∞ and −∞

    • S0 contains all the keys of S in ascending order, and the special keys

    • Sh contains only +∞ and −∞

    • Each list is a (random) subset of the previous one

      • S0 S1 … ⊇ Sh

3
New cards

What is the java implementation of a skip list?

java.util.ConcurrentSkipListMap

4
New cards

List the (4) operations used to traverse a skip list.

  • next(p): Returns the position following p on the same level.

  • prev(p): Returns the position preceding p on the same level.

  • above(p): Returns the position above p in the same tower.

  • below(p): Returns the position below p in the same tower.

5
New cards

Explain how a search for the key k is performed on a skip list.

  • Start at the first position of the top list, then repeat:

    • At the current item p, compare k with next(p)

    • If k == next(p)

      • Return next(p)

    • If k > next(p)

      • “scan forward” // p = next(p)

    • If k < next(p)

      • “drop down” // p = below(p)

    • If we try to drop down past the bottom list, return null, as the item is not in the list.

6
New cards

Explain how an insertion of (k,v) is performed on a skip list.

  • A randomised algorithm is used

  • Perform a search, if the k is found, replace its value with v

  • Otherwise, insert (k,v) in the bottom tower

  • Then ‘flip a coin’ to determine the height of the tower for (k, v)

    • If tails, stop here

    • If head, insert (k,v) into the next level (same tower) and repeat until a tails is flipped

7
New cards

Explain how a deletion of (k,v) is performed on a skip list.

  • Search for k

  • If k is not found, return null

  • Otherwise, remove the element at its position, and all elements above it.

8
New cards

Name the (5) things stored in a skip list quad-node.

  • The element / data

  • Link to previous node

  • Link to next node

  • Link to node below

  • Link to node above

9
New cards

What special keys are required in a skip list?

  • PLUS_INF and MINUS_INF

  • Must modify the key comparator to handle them

10
New cards

What determines the height of a skip list?

  • The randomised insertion algorithm

  • P(tower has a height i) = P(gets i consecutive heads) = 1/2i

  • P(level i has an entry) n/2i

11
New cards

What is the expected space requirement of a skip list?

O(n)

12
New cards

What is the (very likely) height of a skip list?

O(logn)

13
New cards

What is the worst-case time cost of performing a search / deletion / insertion on a skip list?

O(logn)

14
New cards

How can a pseudorandom boolean be generated in java?

nextBoolean()

15
New cards

How can a pseudorandom double between 0.0 and 1.0 be generated in java?

nextDouble()

16
New cards

How can a pseudorandom integer be generated in java?

  • nextInt()

  • nextInt(n) returns a number up to but not including n

Explore top flashcards

322 Exam 1
Updated 991d ago
flashcards Flashcards (78)
abdomen
Updated 815d ago
flashcards Flashcards (29)
Exam 2 Top 300
Updated 620d ago
flashcards Flashcards (56)
25.1!!!
Updated 205d ago
flashcards Flashcards (23)
georgaphy
Updated 989d ago
flashcards Flashcards (42)
Theatre Post 1950
Updated 535d ago
flashcards Flashcards (32)
Substance Abuse
Updated 4d ago
flashcards Flashcards (41)
322 Exam 1
Updated 991d ago
flashcards Flashcards (78)
abdomen
Updated 815d ago
flashcards Flashcards (29)
Exam 2 Top 300
Updated 620d ago
flashcards Flashcards (56)
25.1!!!
Updated 205d ago
flashcards Flashcards (23)
georgaphy
Updated 989d ago
flashcards Flashcards (42)
Theatre Post 1950
Updated 535d ago
flashcards Flashcards (32)
Substance Abuse
Updated 4d ago
flashcards Flashcards (41)