Please Update Following C Code Simple Hash Tables Accept Key String Map String Value Pleas Q37112570

Please Update my following C++ code for Simple HashTables so it will Accept a Key as String and Map to String Value.Please explain each lines of code too;

First Name

Last Name

“Jane”

“Smith”

“John”

“Do”

“Susan”

“Collins”

“Bill”

“Rodgers”

“Eric”

“Jones”

“Bill”

“Wright”

“Mike”

“Bader”

Use Conventional Method Names Insert, Remove,Search:

insert(key, value)

insert(“First”, “Last”)

Search(“First”) → Method will return value

Remove(“First”) → Method will delete key andvalue

//my code

#include<iostream>

#include<cstdlib>

#include<string>

#include<cstdio>

using namespace std;

const int TABLE_SIZE = 128;

/*

* HashEntry Class Declaration

*/

class HashEntry {

   public:

       int key;

       int value;

       HashEntry(int key, intvalue) {

           this->key= key;

           this->value= value; }

};

/*

* HashMap Class Declaration

*/

class HashMap

{

   private:

       HashEntry **table;

   public:

       HashMap() {

           table= new HashEntry * [TABLE_SIZE];

           for(int i = 0; i< TABLE_SIZE; i++) {

               table[i]= NULL; }

       }

       /*

         * HashFunction

         */

       int HashFunc(int key){

           returnkey % TABLE_SIZE; }

       /*

         * InsertElement at a key

         */

           void Insert(int key, int

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.