Download presentation

Presentation is loading. Please wait.

Published byAriel Medina Modified over 2 years ago

1
CSC 172 DATA STRUCTURES

2
SKIP LISTS Read Weiss 10.4.2

3
SKIP LISTS Dictionary Data Structure Efficient

4
SKIP LISTS Dictionary Data Structure (insert delete lookup) Efficient O(lg n)

5
SKIP LISTS Dictionary Data Structure (insert delete lookup) Efficient O(lg n)

6
SKIP LISTS Dictionary Data Structure Efficient (with high probability) Randomized

7
SKIP LISTS Dictionary Data Structure Efficient (with high probability) Randomized Easy to implement

8
LISTS How much time does it take to search a sorted linked list? How can this be improved?

9
EXAMPLE

10
What is this sequence? 14,23,28,34,42,50,59,66,72, 79,86,96,103,110

11
EXAMPLE What is this sequence? 14,23,34,42,50,59,66,72, 79,86,96,103,110

12
EXAMPLE What is this sequence? 14,23,34,42,50,59,66,72, 79,86,96,103,110,116,125

13
SKIP LISTS Use two lists L 2 stores all element L 1 stores some elements Links between shared elements

14
Lookup on a skip list

15
1)Take L1 until you go too far 2)Back up one 3)Transfer to L2 4)Take L2 until you find element (or go too far – not found – or insert)

16
Lookup on a skip list How should we distribute the L1 list? What is the time cost of a search?

17
Lookup on a skip list How should we distribute the L1 list? What is the time cost of a search? Minimize : L1.length + (L2.length/L1.length)

18
NEXT STEP 2 linked lists 2(n^(1/2)) Can we improve this further?

19
NEXT STEP 2 linked lists 2(n^(1/2)) Can we improve this further? 3 linked lists 3(n^(1/3)) k linked lists k(n^(1/k)) N linked lists ???? lg n linked lists lg n (n^(1/lg n))

20
BALLANCED SKIP LISTS Ideal as long as structure is maintained

21
BALLANCED SKIP LISTS Ideal as long as structure is maintained Insertions and deletions mess up structure

22
INSERTION ON SKIP LISTS Search to find location Must insert on bottom list Which other lists? FLIP A COIN If heads add to level above and flip again. If tails done.

23
INSERTION ON SKIP LISTS FLIP A COIN If heads add to level above and flip again. If tails done. ½ of the elements go up one level ¼ of the elements go up 2 levels 1/8 of the elements go up 3 levels

24
INSERTION ON SKIP LISTS EXAMPLE

25
ANALYSIS Intuitively: Height of the structure is O(lg n) How many coin flips do we need to get lg n heads?

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google