Download - Hop, Jump, and Leap
![Page 1: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/1.jpg)
Hop, Jump, and Leap
Dhruv Matani and Gaurav Menghani
![Page 2: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/2.jpg)
Hop, Jump, and Leap*
Dhruv Matani and Gaurav Menghani
* In O(lg n) with high probability
![Page 3: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/3.jpg)
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
![Page 4: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/4.jpg)
Hop, Jump, and Leap
Order Maintenance
O(1) Amortized
Insert
O(1) Query
Static RMQ O(n) pre-processing
O(1) Query
In class, we saw:
![Page 5: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/5.jpg)
Hop, Jump, and Leap
Order Maintenance
O(lg n) w.h.p O(lg n) w.h.p. Query
Dynamic RMQ O(lg n) w.h.p. Insert
O(lg n) w.h.p. Query
Today, we shall see:
![Page 6: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/6.jpg)
Dynamic Range Minimum Query using
Skip Lists
![Page 7: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/7.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
![Page 8: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/8.jpg)
Find element at Index 4
![Page 9: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/9.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
![Page 10: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/10.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
6
![Page 11: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/11.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
1
![Page 12: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/12.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
6
![Page 13: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/13.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
1
![Page 14: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/14.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
3
![Page 15: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/15.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
6
![Page 16: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/16.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
3
![Page 17: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/17.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find the element at index 4
4
![Page 18: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/18.jpg)
Find minimum in range [3, 7]
![Page 19: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/19.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
![Page 20: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/20.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[3,7]
![Page 21: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/21.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[3,7[ = ]3,6[ ,]7,7]
![Page 22: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/22.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[3,6]
[7,7]
![Page 23: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/23.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[3,6]
[7,7]
![Page 24: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/24.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[3,6]
[7,7]
![Page 25: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/25.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[3,6]
![Page 26: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/26.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[3,6[ = ]3,3[ ,]4,6]
![Page 27: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/27.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
![Page 28: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/28.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
[3,3]
![Page 29: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/29.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
[3,3]
![Page 30: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/30.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
[3,3]
![Page 31: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/31.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
[3,3]
![Page 32: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/32.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Find min [3,7]
[7,7]
[4,6]
[3,3]
![Page 33: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/33.jpg)
Insert element with Value 5
at Index 5
![Page 34: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/34.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Insert 5 at index 5
![Page 35: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/35.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Insert 5 at index 5
51
![Page 36: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/36.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Insert 5 at index 5
51
]8,2[]5,2[
![Page 37: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/37.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
85
192
71
85
192
Insert 5 at index 5
51
]8,2[]5,2[52]5,2[
![Page 38: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/38.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
85
192
71
85
192
Insert 5 at index 5
51
]8,2[
52
]5,4[
![Page 39: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/39.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
82
192
71
85
192
Insert 5 at index 5
51
]8,2[
52
]5,4[54]5,4[
![Page 40: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/40.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
82
192
71
85
192
Insert 5 at index 5
51
]8,2[
52
54
]5,4[
![Page 41: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/41.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
82
192
71
56
192
Insert 5 at index 5
51
]8,2[
52
54
]5,4[
![Page 42: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/42.jpg)
71
81
131
301
261
191
241
271
71
262
82
192
71
82
192
71
56
192
Insert 5 at index 5
51
52
54
![Page 43: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/43.jpg)
Order Maintenance using
Skip Lists
![Page 44: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/44.jpg)
• 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
![Page 45: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/45.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Does 13 precede 19?
![Page 46: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/46.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Does 13 precede 19? Rank(13) = 1 + 2 + 1 = 4
![Page 47: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/47.jpg)
71
81
131
301
261
191
241
271
71
262
83
192
71
85
192
71
85
192
Does 13 precede 19? Rank(19) = 1 + 5 + 1 = 7
![Page 48: Hop, Jump, and Leap](https://reader033.vdocuments.us/reader033/viewer/2022051116/568157ef550346895dc5663d/html5/thumbnails/48.jpg)
The End