CS301 – Data Structures
Lecture No. 40
___________________________________________________________________
Data Structures
Lecture No. 40
Reading Material
Data Structures and Algorithm Analysis in C++
Chapter. 10
10.4.2
Summary
•
Skip List
•
Skip List Search
•
Insertion in Skip List
•
Deletion from Skip List
In the previous lecture, we had started the discussion on the concept of the skip lists.
We came across a number of definitions and saw how the use of additional pointers
was effective in the list structures. It was evident from the discussion that a
programmer prefers to keep the data in the linked list sorted. If the data is not sorted,
we cannot use binary search algorithm. And the insert, find and remove methods are
proportional to
n
. But in this case, we want to use the binary search on linked list. For
this purpose, skip list can be used. In the skip list, there is no condition of the upper
limit of the array.
Skip List
A skip list for a set
S
of distinct (key, element) items is a series of lists
S
0
,
S
1
, … ,
S
h
such that
•
Each list
Si
contains the special keys +
∞
and 
∞
•
List
S
0
contains the keys of
S
in nondecreasing order
•
Each
list
is
a
subsequence
of
the
previous
one,
i.e.,
S
0
⊇
S
1
⊇
…
⊇
S
h
•
List
S
h
contains only the two special keys
Now let’s see an example for the skip list. First of all, we have S0 i.e. a linked list. We
did not show the arrows in the list in the figure. The first and last nodes of S0 contain

∞
and +
∞
respectively. In the computer, we can put these values by –max(int) and
max(int). The values can also be used about which we are sure that these will not be
in the data items. However, for the sake of discussion to show these values, the 
∞
and +
∞
are the best notations. We can see that 
∞
is less than any value of data item
while +
∞
is greater than any value of data item. If we insert any value much ever, it is
large the +
∞
will be greater than it. Moreover, we see that the numbers in S0 are in
the non decreasing order. This S0 is the first list in which all keys are present.
Now we will take some nodes from this list and link them. That will be not every
other node or every fourth node. It may happen this way. However, we will try that
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCS301 – Data Structures
Lecture No. 40
___________________________________________________________________
the node should not be every other or fourth node. It will be a random selection. Now
we see S1 i.e. a subset of S0. In S1 we selected the nodes 23, 31, 34 and 64. We have
chosen these nodes randomly with out any order or preference. Now from this S1, we
make S2 by selecting some elements of S1. Here we select only one node i.e. 31 for
the list S2. The additional pointer, here, has to move from 
∞
to 31 and from 31 to +
∞
. Now the next list i.e. S3 will be subset of S2. As there is only one node in S2, so in
S3, there will only the special keys. In these lists, we use pointers to link all the nodes
in S0. Then with additional pointers, we linked these nodes additionally in the other
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 Dr.Naveed Malik
 Data Structures, Array data structure

Click to edit the document details