De Anza College Bounded Hash Table Code

Publish By: Admin,
Last Updated: 17-Aug-23
Price: $120

Abstract

Create a bounded hash table class to store Employee objects. For this HashTable class, collisions are discarded. 

Create a driver to create, insert, and search for Employee objects. 

The driver will provide a looping menu for searching. 

The Employee class is provided.

Use the provided Employee class

The provided Employee class is to be used as-is. 

The hash table will store Employee objects. 

The HashTable class will need to include the Employee class. 

This should be done in the HashTable.h specification file.

The driver:

The driver is a separate file, driver.cpp. The main() function is written here.

  • Create an empty HashTable object.
  • Create *somewhat random Employee objects until the HashTable is full.
  • This will require a for loop. Create an array of letters. Randomly select a random number of characters. Perhaps 1-12 letters. Combine these letters into a name string.
  • The employee numbers could be the loop counter, converted to string.
  • Consider something unique for the hire date string.
  • Combine these values into a new Employee object. Each employee should have unique values.
  •  For each Employee, insert it into the HashTable until the Hash Table is full. This should be a while loop based on the result of yourHashTable.isFull().
  •  If the Employee object can be inserted, the array index is empty, insert the Employee and return true.
  • If the Employee object can NOT be inserted, the array index is occupied, do not insertthe Employee and return False. Also cout a message that the insert failed.
  • Report how many Employee objects could and could not be inserted due to collisions.

 Provide a neatly formatted statistics message before continuing.

Driver looping menu: 

  • Allow user to choose Exit or Search
  • Allow the user to search for employee records. 

? Prompt the user for the name of an Employee to search for.

? Call the search function from your HashTable class.

? Report if the Employee was found or not.

? If the Employee is found, display the employee information to the user.

The HashTableClass must be constructed as follows: 

  • The HashTable class must contain a statically allocated array of type Employee, of size 

1000. Store the maximum of 1000 Employee objects here. 

  • Provide a hash function that returns a key based on the name of the Employee object. 

This must be an int between 0-(array size) only. MUST USE MODULUS. 

  • The hash function takes an Employee object as an argument.
  • The hash function returns an int.
  • The hash function is private.
  • Include isFull() and isEmpty(). These are public.
  • Include a search function that takes a string representing the name of an employee to search for and an Employee &reference. If the Employee is found, this reference will be the set to the found Employee record.
  • Search returns a bool. True if found, False if not.
  • For the HashTable class, create separate specification and implementation files.

 HashTable.h and HashTable.cpp

// Specification file for the Employee class