1 / 26

CSC 172 DATA STRUCTURES

CSC 172 DATA STRUCTURES. SKIP LISTS Read Weiss 10.4.2. SKIP LISTS. Dictionary Data Structure Efficient. SKIP LISTS. Dictionary Data Structure (insert delete lookup) Efficient O(lg n). SKIP LISTS. Dictionary Data Structure (insert delete lookup) Efficient O(lg n). SKIP LISTS.

ella
Download Presentation

CSC 172 DATA STRUCTURES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 172 DATA STRUCTURES

  2. SKIP LISTSRead 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. EXAMPLE 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 L2 stores all element L1 stores some elements Links between shared elements

  14. Lookup on a skip list

  15. Lookup on a skip list Take L1 until you go too far Back up one Transfer to L2 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?

More Related