Implementing a separate chaining technique
Separate chaining is a collision handling technique that will make each cell in the hash table point to a chaining node containing values with the same hash key. We are going to create an ADT named HashTable
to handle the preceding phone number list. Since the phone number contains only numbers, it will be stored in the int
data type, and the owner of the phone number name will be stored in the string
data type. However, if the phone number we have are saved as 123-456-789
format, we need to remove the dash (-) character first.
The HashTable
will be four basic operations and they are:
Insert()
is used to insert a newpair<int, string>
to the hash table. It passes anint
as a key and astring
as a value. It then finds a hash key for the inputted key. If the inputted key is found in the hash table, it will update the value of the key. If no key is found, it will append a new node to the linked list containing the inputted key and inputted value...