Problem

a. Some of the attributes of a state in the United States are its name, capital, area, yea...

a. Some of the attributes of a state in the United States are its name, capital, area, year of admission to the union, and the order of admission to the union. Design the class stateData to keep track of the information for a state. Your class must include appropriate functions to manipulate the state’s data, such as the functions setStatelnfo, getStateInfo, and so on. Also, overload the relational operators to compare two states by their name. For easy input and output, overload the stream operators.

b. b. Use the class hashT as described in the section, “Hashing: Implemen­tation Using Quadratic Probing,’’ which uses quadratic probing to resolve collision, to create a hash table to keep track of each state’s information. Use the state’s name as the key to determine the hash address. You may assume that a state’s name is a string of no more than

14    characters.

Test your program by searching for and removing certain states from the hash table.

You may use the following hash function to determine the hash address of an item:

int hashFunc(string name)

{int i, sum;

int len;

i = 0;

sum = 0;

len = name.length ( );

for (int k = 0; k<15 − len; k++)

name = name + ‘ ’; //increase the length of the name //to 15 characters

for (int k = 0; k<5; k++)

{

sum = sum + static_cast(name[i]) * 128 * 128

+ static_cast(name[i + 1]) * 128

+ static_cast(name[i + 2]);

i = i + 3;}

return sum % HTSize;

}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT