CS 332: Algorithms: Skip Lists Introduction To Hashing
CS 332: Algorithms: Skip Lists Introduction To Hashing
CS 332: Algorithms: Skip Lists Introduction To Hashing
Skip Lists
Introduction to Hashing
h = O(lg n)
We described the properties of red-black trees
We proved that these guarantee h = O(lg n)
We described operations on red-black trees
Only tricky operations: insert, delete
Use rotation to restructure tree
Skip Lists
The basic idea:
level 3
level 2
level 1
12
18
29
35
37
Skip Lists
O(1) expected time for most operations
O(lg n) expected time for insert
O(n2) time worst case (Why?)
But random, so no particular order of insertion
to associated data
Symbols: variable names, procedure names, etc.
Associated data: memory location, call graph, etc.
records
The structure we will use is a hash table
Supports all the above in O(1) expected time!
Hashing: Keys
In the following discussions we will consider
The idea:
Set up an array T[0..m-1] in which
T[i] = x
if x T and key[x] = i
T[i] = NULL
otherwise
This is called a direct-address table
Operations take O(1) time!
So whats the problem?