Hash table C Can not use stl libraries ie vectors hashmap e

Hash table - C++
Can not use stl libraries, ie. vectors, hash_map, etc.

You are to write a program to set up a data base for a phone index. The key will be a person’s name to a table that will supply the phone number. The data base must be implemented as a hash table with the names as the key. The format will be a person name (multiple parts) followed by a phone number.

Example:   John Doe   601-5433   or O E Vay 921-1234. Only one name one phone number will be on an input line.

Set your hash table up to be 45 entries, hash table is 31 in size.

(1.) Print out the final data base (hash table) and indicate how many collisions were made in building the data base.

(2.) After building the Phone Index, show examples of looking up a name and returning a phone number for several names and some of invalid names.

Now I do have some folks (police usually) that have a phone number but need to know the person. So you will create a second hash key capability to use the phone number (hashed) as a key to the data base. Now you ca not create a new hash table since it is anticipated that the table will become quite large and there is only room for one copy of the data that can be maintained. You can though create an index table to access the data base above.

    (3.) Print out the data base (names and phone numbers (hash table)) in the order of the phone hash keys.

      (4.) Now test your phone number look up and show that it works again by returning the name and phone number of several names using the phone number as the key. Show a return of an invalid phone number

Data for program:

Taylor marie 939-1512
james wilis thomas 261-8342
Hewy Lewy Dewy   623-9921
Stone Rock 544-2372
lea high lee 266-8324
stephens reynolds 696-9231
mack russell 123-1234
Lewis Michelle Tee 828-2148
john marshall 888-2891
Mister Rogers   924-7221
Moto hasey 823-8000
Oe vey 177-1423
Twoseeor knocksee 823-8321
Legg T.        587-2839
Znot Noz Oozey 531-4353
Hofstra M.      601-3225
Malioneyh P. J. 287-4344
Morier G. E.    544-2319
Cray Z. Cyco   134-7242
Hauser M.       606-2940
Fanny Pac Jac    842-3242
Sid MacGriddy    882-2424
Currie W. D.    701-4281
Antoney Wenner 999-3255
Hoos R. Dadie   818-3821
Smelly Tau      707-7281
Tobe Ore Knott 613-2414
Bee Yond Lawz   634-2454
Tyson Chicken 602-3152
TooB OrNot   283-5214
SixOne Other 843-2343
Big Tow 384-5624
Juan Legged    882-6246
Tau Jam       532-6871
Zevent Heaven 834-2563
Man Oh Mann     313-7422
E Lec Shaun      709-7424
Sticky Finger McRidder 829-9853
Mighty Mouse 222-2222
G P Morier 832-4562

Solution

1. to create a hash table:

class createHash // class to create hash

{

public:

string Name;

createHash(string name)

{

Name = name;

}

bool operator==(const createHash &make) const

{

return Name == make.Name;

}

};

class finalhash

{

public:

string Name;

int phonenumber;

finalhash(string name, int number)

{

Name = name;

phonenumber= number;

}

bool operator==(const finalhash &model) const

{

return (Name == model.Name && phonenumber == model.phonenumber);

}

};

class checkhash // class to check the value of hash

{

public:

size_t operator()(const finalhash &model) const

{

return hash<string>()(model.Name) ^ hash<int>()(model.phonenumber);

}

};

int main()

{

unordered_map<finalhash createHash, checkhash> model2make;

finalhash james(\"james wilis thomas\", 261-8342);

      

creayeHash james(\"james wilis thomas\");

model2make.emplace(Taylor marie ,939-1512);

model2make.emplace(james wilis thomas ,261-8342);

for (auto &cr1 : model2make)

{

cout << cr1.first.Name << \" \" << cr1.first.phoneNumber << \": \" << cr1.second.Name << endl;

}

return 0;

}

Hash table - C++ Can not use stl libraries, ie. vectors, hash_map, etc. You are to write a program to set up a data base for a phone index. The key will be a pe
Hash table - C++ Can not use stl libraries, ie. vectors, hash_map, etc. You are to write a program to set up a data base for a phone index. The key will be a pe
Hash table - C++ Can not use stl libraries, ie. vectors, hash_map, etc. You are to write a program to set up a data base for a phone index. The key will be a pe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site