Hop Jump and Leap Dhruv Matani and Gaurav

















![Find minimum in range [3, 7] Find minimum in range [3, 7]](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-18.jpg)
![Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 Find min [3, 7] 7 1 8 5 19 2 8 3 19 2](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-19.jpg)
![Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 Find min [3, 7] 7 1 8 5 19 2 8 3 19 2](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-20.jpg)
![Find min [3, 7] = [3, 6], [7, 7] 7 1 7 1 26 Find min [3, 7] = [3, 6], [7, 7] 7 1 7 1 26](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-21.jpg)
![Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-22.jpg)
![Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-23.jpg)
![Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-24.jpg)
![Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 26 2 Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 26 2](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-25.jpg)
![Find min [3, 7] [7, 7] 7 1 7 1 [3, 6] = [3, Find min [3, 7] [7, 7] 7 1 7 1 [3, 6] = [3,](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-26.jpg)
![Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1 Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-27.jpg)
![Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3] Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3]](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-28.jpg)
![Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3] Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3]](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-29.jpg)
![Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1 Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-30.jpg)
![Find min [3, 7] [7, 7] 7 1 7 1 [4, 6] 26 2 Find min [3, 7] [7, 7] 7 1 7 1 [4, 6] 26 2](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-31.jpg)
![Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 Find min [3, 7] 7 1 8 5 19 2 8 3 19 2](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-32.jpg)






![Insert 5 at index 5 7 1 [5, 4] 7 1 26 2 5 Insert 5 at index 5 7 1 [5, 4] 7 1 26 2 5](https://slidetodoc.com/presentation_image_h/79aa6228f56d0f84850a1195aeb1ad55/image-39.jpg)









- Slides: 48
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 datastructure. • Augmenting skip-lists to achieve decent running times for most problems. • By decent, we mean O(lg n) w. h. p
Hop, Jump, and Leap In class, we saw: Order Maintenance Static RMQ O(1) Amortized Insert O(n) preprocessing O(1) Query
Hop, Jump, and Leap Today, we shall see: Order Maintenance O(lg n) w. h. p. Query Dynamic RMQ O(lg n) w. h. p. Insert O(lg n) w. h. p. Query
Dynamic Range Minimum Query using Skip Lists
7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find element at Index 4
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 6 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 1 7 1 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 7 1 6 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 1 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 7 1 3 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 7 1 6 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 7 1 26 2 3 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find the element at index 4 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 4 13 1 8 1 24 1 19 1 27 1
Find minimum in range [3, 7]
Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Find min [3, 7] = [3, 6], [7, 7] 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [3, 6] 7 1 26 2 30 1 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 7 1 [3, 6] = [3, 3], [4, 6] 30 1 26 2 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1 26 2 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3] 7 1 30 1 26 2 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 [3, 3] 30 1 26 2 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 [4, 6] 7 1 30 1 [3, 3] 26 2 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] [7, 7] 7 1 7 1 [4, 6] 26 2 30 1 [3, 3] 26 1 13 1 8 5 19 2 8 3 19 2 24 1 19 1 27 1
Find min [3, 7] 7 1 8 5 19 2 8 3 19 2 7 1 [4, 6] 26 2 30 1 [3, 3] 26 1 13 1 8 1 24 1 [7, 7] 19 1 27 1
Insert element with Value 5 at Index 5
Insert 5 at index 5 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 8 5 19 2 8 3 19 2 7 1 26 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 8 5 19 2 8 3 19 2 7 1 26 2 [5, 2] [8, 2] 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 8 5 19 2 8 2 19 2 7 1 26 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
Insert 5 at index 5 7 1 8 5 19 2 8 2 19 2 [5, 4] [8, 2] 7 1 26 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 [5, 4] 7 1 26 2 5 4 [8, 2] 5 2 8 5 19 2 8 2 19 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 8 5 19 2 5 4 8 2 19 2 5 2 8 2 19 2 [5, 4] [8, 2] 7 1 26 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 5 6 19 2 5 4 8 2 19 2 5 2 8 2 19 2 [5, 4] [8, 2] 7 1 26 2 5 1 7 1 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Insert 5 at index 5 7 1 7 1 26 2 5 6 19 2 5 4 8 2 19 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
Order Maintenance using Skip Lists
• 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
Does 13 precede 19? 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Does 13 precede 19? Rank(13) = 1 + 2 + 1 = 4 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
Does 13 precede 19? Rank(19) = 1 + 5 + 1 = 7 7 1 8 5 19 2 8 3 19 2 7 1 26 2 30 1 26 1 13 1 8 1 24 1 19 1 27 1
The End