1 / 48

Hop, Jump, and Leap

Hop, Jump, and Leap. Dhruv Matani and Gaurav Menghani. Hop, Jump, and Leap *. Dhruv Matani and Gaurav Menghani. * In O(lg n) with high probability. Hop, Jump, and Leap. Skip Lists are a simple and powerful data-structure.

chesmu
Download Presentation

Hop, Jump, and Leap

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. Hop, Jump, and Leap Dhruv Matani and Gaurav Menghani

  2. Hop, Jump, and Leap* Dhruv Matani and Gaurav Menghani * In O(lg n) with high probability

  3. Hop, Jump, and Leap • Skip Lists are a simple and powerful data-structure. • Augmenting skip-lists to achieve decent running times for most problems. • By decent, we mean O(lg n) w.h.p

  4. Hop, Jump, and Leap In class, we saw:

  5. Hop, Jump, and Leap Today, we shall see:

  6. Dynamic Range Minimum Query using Skip Lists

  7. 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  8. Find element at Index 4

  9. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  10. Find the element at index 4 7 1 8 5 19 2 6 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  11. Find the element at index 4 7 1 8 5 19 2 1 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  12. Find the element at index 4 7 1 8 5 19 2 6 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  13. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 1 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  14. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 3 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  15. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 6 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  16. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 3 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  17. Find the element at index 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 4 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  18. Find minimum in range [3, 7]

  19. Find min [3,7] 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  20. Find min [3,7] 7 1 8 5 19 2 [3,7] 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  21. Find min [3,7] [3,7] = [3,6], [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  22. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [3,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  23. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [3,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  24. Find min [3,7] [7,7] 7 1 8 5 19 2 [3,6] 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  25. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [3,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  26. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [3,6] = [3,3], [4,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  27. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  28. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1 [3,3]

  29. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 [3,3] 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  30. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 [3,3] 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  31. Find min [3,7] [7,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 [3,3] 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  32. Find min [3,7] 7 1 8 5 19 2 7 1 8 5 19 2 [4,6] 7 1 26 2 8 3 19 2 [3,3] [7,7] 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  33. Insert element with Value 5 at Index 5

  34. Insert 5 at index 5 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  35. Insert 5 at index 5 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  36. Insert 5 at index 5 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 [5,2] [8,2] 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  37. Insert 5 at index 5 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 5 2 8 2 19 2 [5,2] [5,2] [8,2] 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  38. Insert 5 at index 5 7 1 8 5 19 2 7 1 8 5 19 2 [5,4] [8,2] 7 1 26 2 5 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  39. Insert 5 at index 5 7 1 8 5 19 2 7 1 5 4 8 2 19 2 [5,4] [5,4] [8,2] 7 1 26 2 5 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  40. Insert 5 at index 5 7 1 8 5 19 2 [5,4] [8,2] 7 1 5 4 8 2 19 2 7 1 26 2 5 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  41. Insert 5 at index 5 7 1 5 6 19 2 [5,4] [8,2] 7 1 5 4 8 2 19 2 7 1 26 2 5 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  42. Insert 5 at index 5 7 1 5 6 19 2 7 1 5 4 8 2 19 2 7 1 26 2 5 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  43. Order Maintenance using Skip Lists

  44. To perform Order Maintenance, we insert an element after a given element. • This costs O(lg n) w.h.p • Does X precede Y? • Is the rank(X) < rank(Y)? • This costs O(lg n) w.h.p

  45. Does 13 precede 19? 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  46. Does 13 precede 19? Rank(13) = 1 + 2 + 1 = 4 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  47. Does 13 precede 19? Rank(19) = 1 + 5 + 1 = 7 7 1 8 5 19 2 7 1 8 5 19 2 7 1 26 2 8 3 19 2 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1

  48. The End

More Related