Question: Hi, I need help with my C++ code. I need to implement to search the students by the ID using hashing. Algorithm: Create a class

Hi, I need help with my C++ code. I need to implement to search the students by the ID using hashing.

Algorithm:

Create a class StudentHT that provides for the following struct definitions, instance variables and methods.

struct RecType contains student id, first name, and last name.

struct NodeType contains student id, first name, last name, and a pointer to NodeType

hashPtr an instance variable pointing to hash table array of pointers

a constructor to input hash table size

void insert (RecType item)

will insert an item in the hash table.

item search (RecType item)

Will search an item in hash table and will return it. If not found will return an item containing -1 for id.

void startStatistics ();

void endStatistics ();

void displayStatistics();

Main Method

Provide main method that will create the hash table object and call its methods.

Hashing Algorithm

Calculate the hash index from student id as below:

hash index = (student id) % (total entries in hash table)

Statistics

Provide the following statistics

Total number if ids searched

Total number of nodes searched

Average number of nodes search per id searched

Testing

Use the data in file Add.txt for inserting in the table

Use the data in file Search.txt for doing searches in the hash table.

Add.txt

Pageof 4

ZOOM

200

6929

6618

6741

1948

7601

2154

3286

3917

7909

6296

687

1620

8419

8606

3303

9873

6957

2587

8573

9686

6447

7995

2319

4984

4372

8026

2076

9880

6317

4260

188

7106

1812

7294

4766

6053

4494

2890

8290

5940

8207

6232

8093

5971

2791

2089

5800

4042

2677

4773

4930

163

6470

2252

6715

9916

3199

5873

1420

3657

2408

2635

8157

6259

6016

1390

8470

2595

5584

218

5572

1151

420

1763

879

9156

4200

2353

9530

1621

1264

1240

1194

3827

8395

8730

3210

734

1080

428

4670

7307

3464

6374

2519

8774

7606

4175

4087

6505

5701

9176

7925

4061

3034

2936

1203

1873

9338

3848

1070

2329

788

6528

5926

4360

2274

5506

3102

1890

4667

1540

4262

9867

7821

1188

104

580

8282

8823

144

2695

6481

3635

5151

2512

3454

159

1569

5423

9716

855

237

8748

9546

1795

6157

554

1619

7466

3760

2239

5587

3155

4412

1346

3646

9693

6791

3926

3955

5792

2278

7242

6595

9833

4538

4751

673

5753

5694

6020

4511

2790

1065

1259

6809

1376

6023

4028

8518

1661

9504

7224

3624

7956

1801

9966

2083

234

1985

9832

9310

5082

9424

8829

1768

8837

2786

1258

Search.txt

50

2089

1376

8026

2791

3199

1390

4042

3624

6053

2252

237

6957

6791

6505

2695

3155

2083

1070

4372

3827

8395

3210

4262

6809

3760

7909

4412

8823

4200

6016

2677

2635

3657

8518

8518

2408

879

9424

4061

1620

5971

9693

1420

3454

4984

2274

1768

9546

4061

8419

I need some help. I xpect something because I asked on this website since the last week and nobody answered. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!