2020_S19/wk14/lab14.cpp
For this lab you will write the insert, remove, and search operations for a hash table using open addressing and double hashing for collision resolution; restrictions for this hash table is that we will only store positive integer elements. Remember, a collision is when two or more elements are mapped to the same index. (EMPTY_VAL and DELETED_VAL are not considered data elements within the hash table)
Probe series: table[ (hash1(elem) + hash2(elem) * i++) % CAP ]
while( collision detected and
haven't probed 'n' times ) {
probe for new index
update counter (i)
}
if probed 'n' times
return false
insert elem at table[index]
update count
return true
while( haven't found elem and
haven't hit an empty val and
haven't probed 'n' times ) {
probe for new index
update counter (i)
}
if probed 'n' times
return false -- not in table
assign deleted val at table[index]
update count
return true
while( haven't found elem and
haven't hit an empty val and
haven't probed 'n' times ) {
probe for new index
update counter (i)
}
if table[index] is equal to searched elem
return index
else
return -1