Download presentation

1
CS 225 Lab #11 – Skip Lists

2
Skip List Motivation: sorted arrays are nice for binary search, but they are bad when you add or remove elements alternative to AVL trees Skip List – a probabilistic extension of the linked list data structure to speed up the searching process based on multiple parallel, sorted linked lists has high probability of logarithmic running time

3
**Skip List (2) We want to: Solution:**

create use sorted link lists to achieve logarithmic running times, but there is no mechanism for finding the middle node in a linked list in O(1) time Solution: Have n-levels of linked lists, with each level having probability p that an element exists at that level

4
**Skip List Construction**

Use some probability p that an element appears in the next level of skip lists Start with all elements in the bottom level. Use a pseudo random number generator modulo (1/p) to determine if an element exists in the next level up. Stop this process when no elements are chosen to exist in the next level up

5
Skip List Insertion If p = ½ and we add a new element to the skip list, the following are the probabilities of the element appearing on the next levels: 1 that is it is a level-0 node 1/2 that it is a level-1 node 1/4 that it is a level-2 node 1/8 that it is a level-3 node 1/16 that it is a level-4 node 1/32 that it is a level-5 node

6
**Skip List Insertion (2)**

7
Searching a Skip List Scan Forward Step – move a pointer along the current level until it is at the right-most position on the present level with a key <= k If a node is found that matches the key, returns its value Drop Down Step – if you are not in the bottom row, move down one level in the skip list. If you are, then no element exists with that key

8
**Skip List Implementation**

Today you'll be implementing the Skip List data structure Simplifying Assumptions keys are unique positive integers by default, allocate space for 20 levels our skip lists only store keys, but not data We provided implementation for the insert function, but not remove or find functions

Similar presentations

OK

Advanced Data Structure By Kayman 21 Jan 2006. Outline Review of some data structures Array Linked List Sorted Array New stuff 3 of the most important.

Advanced Data Structure By Kayman 21 Jan 2006. Outline Review of some data structures Array Linked List Sorted Array New stuff 3 of the most important.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Seminar ppt on 3g technology Ppt on solar thermal power plant Ppt on leadership qualities of steve jobs Ppt on water pollution and its control Ppt on famous indian entrepreneurs in america Ppt on friction in our daily life Ppt on environmental pollution Ppt on power system security Ppt on describing words for grade 1 Ppt on capital markets in india