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

MAKE SURE THIS IS procedural code C++ create a hash table for names (first name

ID: 3680137 • Letter: M

Question

MAKE SURE THIS IS procedural code C++

create a hash table for names (first name and last name only, no telephone numbers), and use the following to generate the keys:

unsigned char key = 0;

for (int i = 0; i < fullName.length(); i++)

        key ^= fullName[i];

Your instructor will be using the following list of names to test your program:

Uzoma Acholonu

Giuliana Asmad

Michael Atkins-Combs

Vishnu Bakthisaran

Christopher Blowars

William Bronson

Trevor Butcher

Tiffany Caceres-Bonilla

Dulce Castro

David Cifuentes

Daniel Coursen

Alexandra Davilla

Amanda Dewitt

Alfredo Diaz

Jan Espinosa

Anthony Farrisi

Seth Fenstermaker

Daniella Gabout

Regina Green

Kelly Gregory

Bryan Houser

Michael Jackamorris

Kevin Kim

Benjamin Lee

Kyle Lighting

Perlamassiel Lopez

Omran Losinno

Lisa Maine

Derrike Mason

Andrew McCalla

Alexander McConnell

Niral Modi

Aida Montanez

Christopher Price

Daniyal Raza

Morgan Rex

Andres Rivero

Thomas Rudnicki

Kyle Russell

Samantha Rutkowski

Jaskamal Saini

Kyle Schmidt

Taylor Schnappauf

Ryan Snyder

Heazel Souid

Jason Spiegel

Minh Tang

Tehillah Trauger

Alexis Tocci

Luis Virola

Dale Wenger

Malik White

Jaimie Williams

When done loading the hash table print out the contents of each occupied entry, and any other entries pointed to by an occupied entry in the following format (use tabs, the columns do not have to line up):

Slot 51 is occupied with

Alexandra Davilla Ryan Snyder        

Slot 56 is occupied with

William Bronson            Derrike Mason Taylor Schnappauf        Jason Spiegel

Explanation / Answer

Below are the code for creating a hash table for names and generate the keys:

#include <iostream>

#include <string>

#include <stdlib.h>

#include <stdio.h>

#define size 30

using namespace std;

typedef struct

{

string fulname; // for the filename ... change this to your specification//

}hashd;

hashd hashArray[size]; // tentative

int returnHash(string s)

{

// A simple hashing, no collision handled

int sum=0,ind=0;

for(string::size_type i=0; i < s.length(); i++)

{

sum += s[i];

}

ind = sum % size;

return ind;

}

int main()

{

string Name;

int ind;

cout << "Enter name is - " ;

cin >> Name;

cout << "Enter name is - " + Name << " ";

ind = returnHash(Name);

cout << " Index is - " << ind << " ";

hashArray[ind].fulname = Name;

return 0;

}