Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that: (1) defines and implements a hash class that construct

ID: 3764149 • Letter: W

Question

Write a C++ program that:

(1) defines and implements a hash class that constructs a 23 element array (may be implemented using a vector, a deque, or a list, if you prefer), storing strings, using the following hash function:

              ((first_letter) + (last_letter))%23

So, for example, the word "rocky" would be

    ('r') = 114 + ('y') = 121 = 235%23 = 5

In this example, an attempt would be made to store "rocky" in position 5. In the event of a collision, the word would be stored in the first available location, so if there is a collision in location 5, an attempt would be made to store the word in location 6. If there is a collision in location 6, try location 7 and so on.

(2) the driver program should:

      a. query the user for fifteen words and store them using the hash technique described above.

      b. print out the contents of each position of the array (or vector, deque, or whatever you used), showing vacant as well as filled positions. Remember, only 15 of the 23 positions will be filled.

      c. repeatedly query the user for a target word, hash the word, check for its inclusion in the list of stored words, and report the result. Continue doing this task until the user signals to stop (establish a sentinel condition).

A solution that does not involve defining and using a hash class is not acceptable.

Explanation / Answer

#include #include #include #include #include using namespace std; const int MAXARRAYSIZE = 23; class Hasher { public: Hasher::Hasher() : elementarray(MAXARRAYSIZE) { for(i=0;i 21) sum = 0; else sum++; if (elementarray.at(sum) == "0") { elementarray.at(sum) = hashword; i++; } }while (i != 1) ; } } void hashcheck(char firstlet, char lastlet, string hashword) { sum = (firstlet+lastlet)%23; if (elementarray.at(sum) == "0") cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote