Developing the Insert() operation

To insert a new element in a hash table, first we obtain a hash key from the key's element using HashFunction(). After we have the hash key, we check if the slot is available. If it's not available, we check another free slot using the linear formula we discussed at the beginning of this section. Since the open addressing technique stored all elements in the hash table itself at the beginning of the Insert() function implementation, we need to check if all slots have been occupied. If there is no free slot, the function will do nothing. Each time there's a new element to be added, we increase the currentSize variable to track the total elements in the hash table. The implementation of the function will be ...

Get C++ Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.