chapter 10 maps, hash tables, and skip listsjdenny/courses/prior/16-17...โขassume you have a hash...
TRANSCRIPT
-
CHAPTER 10MAPS, HASH TABLES, AND SKIP LISTSACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH
DATA STRUCTURES AND ALGORITHMS IN JAVA, GOODRICH, TAMASSIA AND
GOLDWASSER (WILEY 2016)
0
1
2
3
4 451-229-0004
981-101-0002
025-612-0001
-
MAPS
โข A map models a searchable collection of key-value entries
โข The main operations of a map are for searching, inserting, and deleting items
โข Multiple entries with the same key are not allowed
โข Applications:โข address book
โข student-record database
โข Often called associative containers
-
THE MAP ADT
โข get(k): if the map ๐ has an entry with key ๐, return its associated value; else, return null
โข put(k, v): insert entry (๐, ๐ฃ) into the map ๐; if key ๐ is not already in ๐, then return null; else, return old value associated with ๐
โข remove(k): if the map๐ has an entry with key ๐, remove it from ๐ and return its associated value; else, return null
โข size(), isEmpty()
โข entrySet(): return an iterable collection of the entries in ๐
โข keySet(): return an iterable collection of the keys in ๐
โข values(): return an iterator of the values in ๐
-
EXAMPLE
โข Operation Output Mapโข isEmpty() true รโข put(5,A) null (5,A)โข put(7,B) null (5,A),(7,B)โข put(2,C) null (5,A),(7,B),(2,C)โข put(8,D) null (5,A),(7,B),(2,C),(8,D)โข put(2,E) C (5,A),(7,B),(2,E),(8,D)โข get(7) B (5,A),(7,B),(2,E),(8,D)โข get(4) null (5,A),(7,B),(2,E),(8,D)โข get(2) E (5,A),(7,B),(2,E),(8,D)โข size() 4 (5,A),(7,B),(2,E),(8,D)โข remove(5) A (7,B),(2,E),(8,D)โข remove(2) E (7,B),(8,D)โข get(2) null (7,B),(8,D)โข isEmpty() false (7,B),(8,D)
-
LIST-BASED MAP
โข We can implement a map with an unsorted list
โข Store the entries in arbitrary order
โข Complexity of get, put, remove?
โข ๐(๐) on put, get, and remove
tailheader nodes/positions
entries
9 c 6 c 5 c 8 c
-
DIRECT ADDRESS TABLE MAP IMPLEMENTATION
โข A direct address table is a map in whichโข The keys are in the range [0, ๐]โข Stored in an array ๐ of size ๐โข Entry with key ๐ stored in ๐[๐]
โข Performance:โข put(k, v), get(k), and remove(k) all take ๐(1) time
โข Space - requires space ๐(๐), independent of ๐, the number of entries stored in the map
โข The direct address table is not space efficient unless the range of the keys is close to the number of elements to be stored in the map, i.e., unless ๐ is close to ๐.
-
SORTED MAP
โข A Sorted Map supports the usual map operations, but also maintains an order
relation for the keys.
โข Naturally supports โข Sorted search tables - store dictionary in
an array by non-decreasing order of the
keys
โข Utilizes binary search
โข Sorted Map ADT adds the following functionality to a map
โข firstEntry(), lastEntry() โreturn iterators to entries with the smallest
and largest keys, respectively
โข ceilingEntry(k), floorEntry(k) โ return an iterator
to the least/greatest key value greater
than/less than or equal to ๐
โข lowerEntry(k), higherEntry(k) โ return an
iterator to the greatest/least key value
less than/greater than ๐
โข etc
-
EXAMPLE OF ORDERED MAP: BINARY SEARCH
โข Binary search performs operation get(k) on an ordered search table
โข similar to the high-low game
โข at each step, the number of candidate items is halved
โข terminates after a logarithmic number of steps
โข Exampleget(7)
1 3 4 5 7 8 9 11 14 16 18 19
1 3 4 5 7 8 9 11 14 16 18 19
1 3 4 5 7 8 9 11 14 16 18 19
1 3 4 5 7 8 9 11 14 16 18 19
0
0
0
0
ml h
ml h
ml h
l=m =h
-
SIMPLE MAP IMPLEMENTATION SUMMARY
put(k, v) get(k) Space
Unsorted list ๐(๐) ๐(๐) ๐(๐)
Direct Address Table ๐(1) ๐(1) ๐(๐)
Sorted Search Table
(Naturally supported Sorted Map)
๐(๐) ๐(log ๐) ๐(๐)
-
DEFINITIONS
โข A set is an unordered collection of elements, without duplicates that typically supports efficient membership tests.
โข Elements of a set are like keys of a map, but without any auxiliary values.
โข A multiset (also known as a bag) is a set-like container that allows duplicates.
โข A multimap (also known as a dictionary) is similar to a traditional map, in that it associates values with keys; however, in a multimap the same key can be
mapped to multiple values.
โข For example, the index of a book maps a given term to one or more locations at which the term occurs.
-
SET ADT
-
GENERIC MERGING
โข Generalized merge of two sorted lists A and B
โข Template method genericMerge
โข Auxiliary methodsโข aIsLess
โข bIsLess
โข bothAreEqual
โข Runs in ๐(๐๐ด + ๐๐ต) time provided the auxiliary methods run in ๐(1) time
Algorithm genericMerge(A, B)
Input: Sets A,B as sorted lists
Output: Set ๐1. ๐ โ โ 2. while ยฌ๐ด.isEmpty()โง ยฌ๐ต.isEmpty() do3. ๐ โ ๐ด.first(); ๐ โ ๐ต.first()4. if ๐ < ๐5. aIsLess(a, S) //generic action6. ๐ด.removeFirst();7. else if ๐ < ๐8. bIsLess(b, S) //generic action9. ๐ต.removeFirst()10. else //๐ = ๐11. bothAreEqual(a, b, S) //generic action12. ๐ด.removeFirst(); ๐ต.removeFirst()13.while ยฌ๐ด.isEmpty() do14. aIsLess(A.first(), S); ๐ด.eraseFront()15.while ยฌ๐ต.isEmpty() do16. bIsLess(B.first(), S); ๐ต.removeFirst()17.return ๐
-
USING GENERIC MERGE FOR SET OPERATIONS
โข Any of the set operations can be implemented using a generic merge
โข For example:
โข For intersection: only copy elements that are duplicated in both list
โข For union: copy every element from both lists except for the duplicates
โข All methods run in linear time
-
MULTIMAP
โข A multimap is similar to a map, except that it can store multiple entries with the same key
โข We can implement a multimap ๐ by means of a map ๐โฒ
โข For every key ๐ in ๐, let ๐ธ(๐) be the list of entries of ๐ with key ๐
โข The entries of ๐โฒ are the pairs (๐, ๐ธ(๐))
-
MULITMAPS
-
HASH TABLES
-
INTUITIVE NOTION OF A MAP
โข Intuitively, a map ๐ supports the abstraction of using keys as indices with a syntax such as ๐ ๐ .
โข As a mental warm-up, consider a restricted setting in which a map with ๐ items uses keys that are known to be integers in a range from 0 to ๐ โ 1, for some
๐ โฅ ๐.
-
MORE GENERAL KINDS OF KEYS
โข But what should we do if our keys are not integers in the range from 0 to ๐โ1?
โข Use a hash function to map general keys to corresponding indices in a table.
โข For instance, the last four digits of a Social Security number.
01234 451-229-0004
981-101-0002
025-612-0001
โฆ
-
HASH TABLES
โข A Hash function โ ๐ โ [0,๐ โ 1]
โข The integer โ(๐) is referred to as the hash value of key ๐
โข Example - โ ๐ = ๐ mod ๐ could be a hash function for integers
โข Hash tables consist ofโข A hash function โ
โข Array ๐ด of size ๐ (either to an element itself or to a โbucketโ)
โข Goal is to store elements ๐, ๐ฃ at index ๐ = โ ๐
-
ISSUES WITH HASH TABLES
โข Issues
โข Collisions - some keys will map to the same index of H (otherwise we have a Direct Address Table).
โข Chaining - put values that hash to same location in a linked list (or a โbucketโ)
โข Open addressing - if a collision occurs, have a method to select another location in the table.
โข Load factor
โข Rehashing
-
EXAMPLE
โข We design a hash table for a Map storing items (SSN, Name), where
SSN (social security number) is a
nine-digit positive integer
โข Our hash table uses an array of size๐ = 10,000 and the hash function
โ ๐ = last four digits of ๐
0
1
2
3
4
9997
9998
9999
โฆ451-229-0004
981-101-0002
200-751-9998
025-612-0001
-
HASH FUNCTIONS
โข A hash function is usually specified as the composition of two functions:
โข Hash code:โ1: keys integers
โข Compression function:โ2: integers [0, ๐ โ 1]
โข The hash code is applied first, and the compression function is applied
next on the result, i.e.,
โ ๐ = โ2 โ1 ๐
โข The goal of the hash function is to โdisperseโ the keys in an apparently
random way
-
HASH CODES
โข Memory address:โข We reinterpret the memory address of the
key object as an integer
โข Good in general, except for numeric and string keys
โข Integer cast:โข We reinterpret the bits of the key as an
integer
โข Suitable for keys of length less than or equal to the number of bits of the integer type (e.g.,
byte, short, int and float in C++)
โข Component sum:โข We partition the bits of the key into
components of fixed length (e.g., 16 or
32 bits) and we sum the components
(ignoring overflows)
โข Suitable for numeric keys of fixed length greater than or equal to the
number of bits of the integer type (e.g.,
long and double in C++)
-
HASH CODES
โข Polynomial accumulation:โข We partition the bits of the key into a
sequence of components of fixed length
(e.g., 8, 16 or 32 bits)
๐0๐1โฆ๐๐โ1
โข We evaluate the polynomial๐ ๐ง = ๐0 + ๐1๐ง + ๐2๐ง
2 +โฏ+ ๐๐โ1๐ง๐โ1
at a fixed value z, ignoring overflows
โข Especially suitable for strings (e.g., the choice z = 33 gives at most 6 collisions on a
set of 50,000 English words)
โข Cyclic Shift:
โข Like polynomial accumulation except use bit shifts instead of multiplications
and bitwise or instead of addition
โข Can be used on floating point numbers as well by converting the
number to an array of characters
-
COMPRESSION FUNCTIONS
โข Division:
โข โ2 ๐ = ๐ mod ๐
โข The size N of the hash table is usually chosen to be a prime
โข The reason has to do with number theory and is beyond the scope of this
course
โข Multiply, Add and Divide (MAD):
โข โ2 ๐ = ๐๐ + ๐ mod ๐
โข ๐ and ๐ are nonnegative integers such that
๐ mod ๐ โ 0
โข Otherwise, every integer would map to the same value ๐
-
COLLISION RESOLUTION WITHSEPARATE CHAINING
โข Collisions occur when different elements are mapped to the same
cell
โข Separate Chaining: let each cell in the table point to a linked list of
entries that map there
โข Chaining is simple, but requires additional memory outside the table
0
1
2
3
4 451-229-0004 981-101-0004
025-612-0001
-
EXERCISESEPARATE CHAINING
โข Assume you have a hash table ๐ป with ๐ = 9 slots (๐ด[0 โ 8]) and let the hash function be โ ๐ = ๐ mod ๐
โข Demonstrate (by picture) the insertion of the following keys into a hash table with collisions resolved by chaining
โข 5, 28, 19, 15, 20, 33, 12, 17, 10
-
COLLISION RESOLUTION WITHOPEN ADDRESSING - LINEAR PROBING
โข In Open addressing the colliding item is placed in a different cell of the table
โข Linear probing handles collisions by placing the colliding item in the next (circularly)
available table cell. So the ๐th cell checked is:โ ๐, ๐ = โ ๐ + ๐ mod ๐
โข Each table cell inspected is referred to as a โprobeโ
โข Colliding items lump together, causing future collisions to cause a longer probe sequence
โข Example:
โข โ ๐ = ๐ mod 13
โข Insert keys 18, 41, 22, 44, 59, 32, 31, 73, in this order
0 1 2 3 4 5 6 7 8 9 10 11 12
41 18 44 59 32 22 31 73
0 1 2 3 4 5 6 7 8 9 10 11 12
-
SEARCH WITH LINEAR PROBING
โข Consider a hash table A that uses linear probing
โข get(k)โข We start at cell โ ๐
โข We probe consecutive locations until one of the following occurs
โข An item with key ๐ is found, or
โข An empty cell is found, or
โข ๐ cells have been unsuccessfully probed
Algorithm get(k)
1. ๐ โ โ ๐2. ๐ โ 03. repeat4. ๐ โ ๐ด ๐5. if ๐ โ โ 6. return ๐๐ข๐๐7. else if ๐.key()= ๐8. return ๐9. else10. ๐ โ ๐ + 1 mod ๐11. ๐ โ ๐ + 112. until ๐ = ๐13. return ๐๐ข๐๐
-
UPDATES WITH LINEAR PROBING
โข To handle insertions and deletions, we introduce a special object, called
DEFUNCT, which replaces deleted
elements
โข remove(k)โข We search for an item with key ๐
โข If such an item ๐, ๐ฃ is found, we replace it with the special item DEFUNCT
โข Else, we return null
โข put(k, v)
โข We start at cell โ(๐)
โข We probe consecutive cells until one of the following occurs
โข A cell ๐ is found that is either empty or stores DEFUNCT, or
โข ๐ cells have been unsuccessfully probed
-
EXERCISEOPEN ADDRESSING โ LINEAR PROBING
โข Assume you have a hash table ๐ป with ๐ = 11 slots (๐ด[0 โ 10]) and let the hash function be โ ๐ = ๐ mod ๐
โข Demonstrate (by picture) the insertion of the following keys into a hash table with collisions resolved by linear probing.
โข 10, 22, 31, 4, 15, 28, 17, 88, 59
-
COLLISION RESOLUTION WITHOPEN ADDRESSING โ QUADRATIC PROBING
โข Linear probing has an issue with clustering
โข Another strategy called quadratic probing uses a hash functionโ ๐, ๐ = โ ๐ + ๐2 mod ๐
for ๐ = 0, 1,โฆ ,๐ โ 1
โข This can still cause secondary clustering
-
COLLISION RESOLUTION WITHOPEN ADDRESSING - DOUBLE HASHING
โข Double hashing uses a secondary hash function โ2(๐) and handles collisions by placing an item in the first available cell of
the series
โ ๐, ๐ = โ1 ๐ + ๐โ2 ๐ mod ๐
for ๐ = 0, 1, โฆ , ๐ โ 1
โข The secondary hash function โ2 ๐ cannot have zero values
โข The table size ๐ must be a prime to allow probing of all the cells
โข Common choice of compression map for the secondary hash function:
โ2 ๐ = ๐ โ ๐ mod ๐
where
โข ๐ < ๐
โข ๐ is a prime
โข The possible values for โ2 ๐ are 1, 2, โฆ , ๐
-
PERFORMANCE OF HASHING
โข In the worst case, searches, insertions and removals on a hash table take ๐ ๐ time
โข The worst case occurs when all the keys inserted into the map collide
โข The load factor ๐ผ = ๐๐
affects the performance of
a hash table
โข Assuming that the hash values are like random numbers, it can be shown that the expected number
of probes for an insertion with open addressing is1
1 โ ๐ผ=1
1 โ ๐ ๐=1
๐ โ ๐ ๐
=๐
๐ โ ๐
โข The expected running time of all the Map ADT operations in a hash table is ๐ 1
โข In practice, hashing is very fast provided the load factor is not close to 100%
โข Applications of hash tablesโข Small databases
โข Compilers
โข Browser caches
-
UNIFORM HASHING ASSUMPTION
โข The probe sequence of a key ๐ is the sequence of slots probed when looking for ๐
โข In open addressing, the probe sequence is โ ๐, 0 , โ ๐, 1 , โฆ , โ ๐,๐ โ 1
โข Uniform Hashing Assumption
โข Each key is equally likely to have any one of the ๐! permutations of {0, 1, โฆ ,๐ โ 1} as is probe sequence
โข Note: Linear probing and double hashing are far from achieving Uniform Hashing
โข Linear probing: ๐ distinct probe sequences
โข Double Hashing: ๐2 distinct probe sequences
-
PERFORMANCE OF UNIFORM HASHING
โข Theorem: Assuming uniform hashing and an open-address hash table with load
factor ๐ผ =๐
๐< 1, the expected number of probes in an unsuccessful search is
at most 1
1โ๐ผ.
โข Exercise: compute the expected number of probes in an unsuccessful search in
an open address hash table with ๐ผ =1
2, ๐ผ =
3
4, and ๐ผ =
99
100.
-
ON REHASHING
โข Keeping the load factor low is vital for performance
โข When resizing the table:
โข Reallocate space for the array (of size that is a prime)
โข Design a new hash function (new parameters) for the new array size (practically, change the mod)
โข For each item you reinsert into the table rehash
-
SUMMARY MAPS (SO FAR)
put(k, v) get(k) Space
Unsorted list ๐(๐) ๐(๐) ๐(๐)
Direct Address Table ๐(1) ๐(1) ๐(๐)
Sorted Search Table
(Naturally supported Sorted Map)
๐(๐) ๐(log ๐) ๐(๐)
Hashing
(chaining)๐๐
๐๐๐
๐๐(๐ + ๐)
Hashing
(open addressing)๐1
1 โ๐๐
๐1
1 โ๐๐
๐(๐)
-
SKIP LISTS
+-
S0
S1
S2
S3
+- 10 362315
+- 15
+- 2315
-
RANDOMIZED ALGORITHMS
โข A randomized algorithm controls its execution through random selection (e.g., coin tosses)
โข It contains statements like:๐ โ randomBit()
if ๐ = 0
do somethingโฆ
else //๐ = 1
do something elseโฆ
โข Its running time depends on the outcomes of the โcoin tossesโ
โข Through probabilistic analysis we can derive the expected running time of a randomized algorithm
โข We make the following assumptions in the analysis:โข the coins are unbiased
โข the coin tosses are independent
โข The worst-case running time of a randomized algorithm is often large but has very low probability (e.g., it occurs
when all the coin tosses give โheadsโ)
โข We use a randomized algorithm to insert items into a skip list to insert in expected ๐(log ๐)โtime
โข When randomization is used in data structures they are referred to as probabilistic data structures
-
WHAT IS A SKIP LIST?
โข A skip list for a set S of distinct (key, element) items is a series of lists ๐0, ๐1, โฆ , ๐โ
โข Each list ๐๐ contains the special keys +โ and โโ
โข List ๐0 contains the keys of ๐ in non-decreasing order
โข Each list is a subsequence of the previous one, i.e.,๐0 โ ๐1 โ โฏ โ ๐โ
โข List ๐โ contains only the two special keys
โข Skip lists are one way to implement the Ordered Map ADT
โข Java applet
56 64 78 +31 34 44- 12 23 26
+-
+31-
64 +31 34- 23
S0
S1
S2
S3
http://www.cs.umd.edu/class/spring2002/cmsc420-0401/demo/SkipList2/
-
IMPLEMENTATION
โข We can implement a skip list with quad-nodes
โข A quad-node stores:โข (Key, Value)
โข links to the nodes before, after, below, and above
โข Also, we define special keys +โ and โโ, and we modify the key comparator to handle them
x
quad-node
-
SEARCH - GET(K)
โข We search for a key ๐ in a skip list as follows:โข We start at the first position of the top list โข At the current position ๐, we compare ๐ with ๐ฆ โ ๐. next(). key()๐ฅ = ๐ฆ: we return ๐. next(). value()๐ฅ > ๐ฆ: we scan forward๐ฅ < ๐ฆ: we drop down
โข If we try to drop down past the bottom list, we return null
โข Example: search for 78
+-
S0
S1
S2
S3
+31-
64 +31 34- 23
56 64 78 +31 34 44- 12 23 26
-
EXERCISESEARCH
โข We search for a key ๐ in a skip list as follows:โข We start at the first position of the top list โข At the current position ๐, we compare ๐ with ๐ฆ โ ๐. next(). key()๐ฅ = ๐ฆ: we return ๐. next(). value()๐ฅ > ๐ฆ: we scan forward๐ฅ < ๐ฆ: we drop down
โข If we try to drop down past the bottom list, we return NO_SUCH_KEY
โข Ex 1: search for 64: list the (๐๐, node) pairs visited and the return value
โข Ex 2: search for 27: list the (๐๐, node) pairs visited and the return value
+-
S0
S1
S2
S3
+31-
64 +31 34- 23
56 64 78 +31 34 44- 12 23 26
-
INSERTION - PUT(K, V)
โข To insert an item (๐, ๐ฃ) into a skip list, we use a randomized algorithm:โข We repeatedly toss a coin until we get tails, and we denote with ๐ the number of times the coin came up heads
โข If ๐ โฅ โ, we add to the skip list new lists ๐โ+1, โฆ , ๐๐+1 each containing only the two special keys
โข We search for ๐ in the skip list and find the positions ๐0, ๐1, โฆ , ๐๐ of the items with largest key less than ๐ in each list ๐0, ๐1, โฆ , ๐๐
โข For ๐ โ 0,โฆ , ๐, we insert item (๐, ๐ฃ) into list ๐๐ after position ๐๐
โข Example: insert key 15, with ๐ = 2
+-
S0
S1
S2
S3
+- 10 362315
+- 15
+- 2315
+- 10 36
+-
23
23 +-
S0
S1
S2
p0
p1
p2
-
DELETION - REMOVE(K)
โข To remove an item with key ๐ from a skip list, we proceed as follows:
โข We search for ๐ in the skip list and find the positions ๐0, ๐1, โฆ , ๐๐ of the items with key ๐, where position ๐๐ is in list ๐๐
โข We remove positions ๐0, ๐1, โฆ , ๐๐ from the lists ๐0, ๐1, โฆ , ๐๐
โข We remove all but one list containing only the two special keys
โข Example: remove key 34
- +4512
- +
23
23- +
S0
S1
S2
- +
S0
S1
S2
S3
- +4512 23 34
- +34
- +23 34p0
p1
p2
-
SPACE USAGE
โข The space used by a skip list depends on the random bits used by each invocation of
the insertion algorithm
โข We use the following two basic probabilistic facts:
โข Fact 1: The probability of getting ๐consecutive heads when flipping a coin is
1
2๐
โข Fact 2: If each of ๐ items is present in a set with probability ๐, the expected size of the set is ๐๐
โข Consider a skip list with ๐ itemsโข By Fact 1, we insert an item in list ๐๐ with
probability 1
2๐
โข By Fact 2, the expected size of list ๐๐ is ๐
2๐
โข The expected number of nodes used by the skip list is
๐=0
โ๐
2๐= ๐
๐=0
โ1
2๐< 2๐
โข Thus the expected space is ๐ 2๐
-
HEIGHT
โข The running time of find ๐ , put ๐, ๐ฃ , and erase ๐ operations are affected by the height โ of the skip list
โข We show that with high probability, a skip list with ๐ items has height ๐ log ๐
โข We use the following additional probabilistic fact:
โข Fact 3: If each of ๐ events has probability ๐, the probability that at least one event occurs
is at most ๐๐
โข Consider a skip list with ๐ itemsโข By Fact 1, we insert an item in list ๐๐ with
probability 1
2๐
โข By Fact 3, the probability that list ๐๐ has at least one item is at most
๐
2๐
โข By picking ๐ = 3 log ๐, we have that the probability that ๐3 log ๐ has at least one
item is
at most ๐
23 log ๐=๐
๐3=1
๐2
โข Thus a skip list with ๐ items has height at most 3 log ๐ with probability at least 1 โ
1
๐2
-
SEARCH AND UPDATE TIMES
โข The search time in a skip list is proportional toโข the number of drop-down steps
โข the number of scan-forward steps
โข The drop-down steps are bounded by the height of the skip list and thus are ๐ log ๐expected time
โข To analyze the scan-forward steps, we use yet another probabilistic fact:
โข Fact 4: The expected number of coin tosses required in order to get tails is 2
โข When we scan forward in a list, the destination key does not belong to a higher list
โข A scan-forward step is associated with a former coin toss that gave tails
โข By Fact 4, in each list the expected number of scan-forward steps is 2
โข Thus, the expected number of scan-forward steps is ๐(log ๐)
โข We conclude that a search in a skip list takes ๐ log ๐ expected time
โข The analysis of insertion and deletion gives similar results
-
EXERCISE
โข You are working for ObscureDictionaries.com a new online start-up which specializes in sci-fi languages. The CEO wants your team to describe a data structure which will
efficiently allow for searching, inserting, and deleting new entries. You believe a skip
list is a good idea, but need to convince the CEO. Perform the following:
โข Illustrate insertion of โX-wingโ into this skip list. Randomly generated (1, 1, 1, 0).
โข Illustrate deletion of an incorrect entry โEnterpriseโ
โข Argue the complexity of deleting from a skip list
- +YodaBoba Fett
- +
Enterprise
Enterprise- +
S0
S1
S2
-
SUMMARY
โข A skip list is a data structure for dictionaries that uses a randomized
insertion algorithm
โข In a skip list with ๐ items
โข The expected space used is ๐ ๐
โข The expected search, insertion and deletion time is ๐(log ๐)
โข Using a more complex probabilistic analysis, one can show that these
performance bounds also hold with
high probability
โข Skip lists are fast and simple to implement in practice