Escolar Documentos
Profissional Documentos
Cultura Documentos
6.046J/18.401J/SMA5503
Lecture 7
Prof. Charles E. Leiserson
Symbol-table problem
Symbol table T holding n records:
record
x Operations on T:
key[x]
key[x]
• INSERT(T, x)
• DELETE(T, x)
Other fields
containing • SEARCH(T, k)
satellite data
k1 h(k1)
k5 h(k4)
K k4 h(k2) = h(k5)
k2 k3
h(k3)
U
m–1
When a record to be inserted maps to an already
As each key
occupied slotisininserted, h maps
T, a collision it to a slot of T.
occurs.
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 11 L7.4
Resolving collisions by
chaining
• Records in the same slot are linked into a list.
T
i 49
49 86
86 52
52
h(49) = h(86) = h(52) = i
204 collision
481
m–1
204
481
m–1
m–1