Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

From D.S. Malik, Data Strucutres Using C++, Chapter 9 Programming Exercise 8 8. a. Some of the attributes of a state in the United States

From D.S. Malik, Data Strucutres Using C++, Chapter 9 Programming Exercise 8

8. 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

states data, such as the functions setStateInfo, 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. Use the class hashT as described in the section, Hashing: Implementation

Using Quadratic Probing, which uses quadratic probing to

resolve collision, to create a hash table to keep track of each states

information. Use the states name as the key to determine the hash

address. You may assume that a states name is a string of no more than

15 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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Briefly explain the various types of leadership ?

Answered: 1 week ago

Question

Explain the need for and importance of co-ordination?

Answered: 1 week ago

Question

Explain the contribution of Peter F. Drucker to Management .

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago