SUNY Geneseo Department of Computer Science
Tuesday, April 23
CSci 242, Spring 2013
Prof. Doug Baldwin
Example (simple): build a hash table keyed by day number in year (1 - 365) containing holiday information, e.g., (1, New Years Day), (33, Ground Hog Day), etc.
class HolidayTable
string[ 0 .. 365 ] T
insert( d, name )
if T[d] == empty
T[d] = name
else
T[d] = T[d] + "and" + name
search( d )
return T[d]
delete( d )
T[d] = empty
hash( d )
return d % 20
insert( d, name )
q = hash( d )
InsertFront( T[q], <d,name> )
search( d )
q = hash( d )
b = find( T[q], d )
return name( b )
Hashing string keys
Hand out hashing homework
Analysis of hashing
Read