Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a software program in either C++ or Java that stores and searches the Student records using separate-chaining hashing algorithm. In separate-chaining hashing, keys are

Implement a software program in either C++ or Java that stores and searches the Student records using separate-chaining hashing algorithm. In separate-chaining hashing, keys are stored in linked lists or other collection data structures attached to cells of a hash table. Each list or collection contains all the keys hashed to its cell.

The software program will be based on the following requirements:

Development Environment:

  • If the software program is written in C++, its project must be created using Microsoft Visual Studio 2017.
  • If the software program is written in Java, its project must be created using NetBeans v8.2.

Algorithm:

  • The hash function is defined as:
    • hashValue = (Key % TABLE_SIZE) Where Key is the ID of the Student record (Refer to the Student class definition below) and TABLE_SIZEis the number of slots in the hash table.
  • When the new Student record is to be inserted, the following steps will occur:
    • A hash value (hashValue) is computed using the hash function.
    • Using the computed hash value (hashValue) as an index in the hash table, retrieve the data list or collection.
    • Insert the Student record into this data list or collection.
  • To search for a Student record by the Student ID, apply the similar steps as described in the insertion steps.

Classes:

  • The software program will have three classes. The requirements for each class are define as followings:
    • Class Student This class must at least include the following properties:
      • Student first name (required/non-null)
      • Student last name (required/non-null)
      • Student middle name (optional)
      • Student ID (required)
    • Class StudentHash This class will have the following methods with their signatures as listed below:
      • StudentHash (Constructor)
        • The constructor has one parameter.This parameter will be the number of slots in the hash table.
        • It will create and initialize the hash table (Notes: The hash table must not be publicly exposed).
      • Add()
        • This method will receive a Student record.It will try to insert the given Student record in the hash table that belongs to this class.
        • If the Student record is inserted successfully, it will return true. Otherwise, it returns false.
      • Search()
        • This method will receive the Student ID used to look up for a Student record by Student ID previously inserted into the hash table.
        • If found, it will return the Student record.
        • Otherwise, it will return null.
      • PrintRecords()
        • This method has no input parameters.
        • It will display the Student record data that have been inserted in the hash table.
        • No return value from this function is needed.
    • Class StudentHashDriver This class will contain the implementation of the main() method of the program.The following tasks will need to be implemented:
      • There will be 3options:
        • Option 1 Allow the user to enter Student records and add them in the hash table of the StudentHash class.
        • Option 2 Allow the user to search for a Student record by the Student ID.
        • Option 3 Print out the contents of the hash table.
      • Option 1:
        • Prompt the user for the number of Student records to be entered.
        • Create an instance of the StudentHashclass, passing the number of slots in the hash table through the constructor of the StudentHashclass.
        • Prompt the user to enter Student data.
        • Add the Student data to the hash table of the StudentHash class.
      • Option 2:
        • Prompt the user for the Student ID.
        • Search for the Student record in the hash table using this ID.
        • If found, display the Student data.
        • Otherwise, report to the user that no Student record can be found using this ID.
      • Option 3:

Print the contents of the hash table.

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

answer the question wit a 150 word count helpp

Answered: 1 week ago