Developing a Search() operation

In a Search() operation, we will get the value of an inputted key. To do so, first we need to find out the hash key of the inputted key. Similar to the Insert() operation, we traverse to the chaining node in the cell pointed by the hash key to find if the key. If the key is found, we just need to return the value of the key. If not, the empty string will be returned instead. The implementation of the Search() operation should be as follows:

string HashTable::Search(int key){    // Get hash key from hash function    int hashKey = HashFunction(key);    // Iterate through chaining node (linked list)    // in selected cell    for (auto &keyValue : tableList[hashKey])    {        // if the key is found        // return the value of name if (keyValue.first ...

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.