Write a C++ program that: (1) defines and implements a hash class that constructs a 23 element
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:
(ascii(first_letter) + ascii (last_letter))#
So, for example, the word "rocky" would be
ascii('r) = 114 + ascii ('y') = 121 = 235# = 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).
Digital Signal Processing
ISBN: ?978-0133737622
3rd Edition
Authors: Jonh G. Proakis, Dimitris G.Manolakis