skip1 - Advanced List Structures Skip Lists(1 Introduction...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction Linked lists have one serious drawback: They require sequential scanning to locate an element during a search. The search must start from the beginning of the list and terminates when either the search element is found or the end of the list is encountered without finding the search element. Ordering the elements in the list can speed up the searching, but a linear (sequential) search is still required. There have been several hybrid list structures that have been developed which allow searching in a list to occur in other than sequential fashion. Most commonly these techniques allow the search to “skip over” certain nodes in the list to avoid the cost of the sequential search. The skip list is one such variant of the ordered list which make nonsequential searching possible. [ Reference: Pugh, William, “Skip Lists: A Probabilistic Alternative to Balanced Trees,” Communications of the ACM 33 (6), (1990), 668-676.] A Simple Skip List Can you think of a simple way to reduce the worst case “cost” (in terms of the potential number of comparisons that need to be made against the search element) of a search in an ordered linear list of n nodes from n comparisons to n/2+1 comparisons? The way to do this is to maintain one additional pointer (reference) to the middle element in the list. With this single additional reference, all searches begin with a comparison against this middle list element. If the search is for an element smaller than the middle element, the only the left- half of the list need to be searched and if the search element is larger than the middle element, only the right-half of the list will be searched. This technique is basically the simplest form of a skip list. In general, skip lists will reduce the cost of a given search much more dramatically, as we will shortly discover. Figures 1 and 2 shown below, illustrate the simple skip list principle. (Figure 1) A simple ordered linked list with head and tail nodes Skip Lists - 1 Advanced List Structures – Skip Lists (1) 20 24 30 40 60 75 80
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Now consider the simple ordered list shown above with the addition of a single pointer to the middle of the list, which in this case is the node containing the element 40. This new list is shown in the Figure 2. (Figure 2) A simple skip list with a pointer to the middle of the list The number of nodes in the list in the two figures above is seven. If the search in the original ordered list were for the value 80, exactly seven ( n ) comparisons with values in the list would be performed before the search element was located in the list. Using the simple skip list the number of comparisons for this search decreases to exactly four ( n/2+1 ). Skip Lists
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/13/2011.

Page1 / 11

skip1 - Advanced List Structures Skip Lists(1 Introduction...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online