$29
Write a C++ program that does the following :
1. Create an integer array of size 30. Assign * to each location in the array
indicating that the array is empty..
2. Populate half of the array with random integer values between 125 and 425
inclusive. Use the following formula in order to hash and store each number in its
proper position/location.
Generated Number % Table Size;
3. Should a collision occurs , use linear probing to find next available position /
location. Use the following probing hashing function.
( Generated Number + 1 ) % Table Size;
4. Display and introduction message followed by the generated array. The generated
array should be displayed in 2 lines. Each line contain 15 numbers separated by 2
spaces
The program then displays a menu on the screen allowing the user to do the following :
1. Display the generated array.
2. Search for a number ( between 125 – 425 ) in the array.
3. Insert new number ( between 125 – 425 ) in the array.
4. Delete a number ( between 125 – 425 ) from the array.
5. End the program
Upon program termination ; The program shall display the following statistical
information
• The number of linear probes when each number is hashed and collision
occurred when adding an element in the array.
• Include a signature line with your name – see sample run.
NOTES:
• Must use and modify the program that is provided in the my
Hashing lecture notes.
• Just one .cpp file.
• A Message is displayed when searching for a number and
number is not found.
• A Message is displayed when deleting a number and number is
not found.
• Modify the search and delete functions such that the functions
uses hashing and rehashing functions when searching and
deleting numbers form the table. You are not allowed to use
sequential search for locating and deleting number from the
tables.
• Validation on menu selection items.
Rules :
1. This program must be done as an individual . Group work will not be accepted and a
grade of zero will be assigned.
2. Your program must compile and run. The program will be tested using the latest
version of Codeblocks for windows. No grades will be given for a program that
compiles but does not run.
3. You re not allowed vectors , linked lists. Must only use arrays.
4. Your program must be properly documented according the style above . See the
website for the sample programming style program.
5. You must name your program as :
o 3358_0_LastName_FirstName_Optional_PG7.cpp
o 3358_1_LastName_FirstName_Optinoal_PG7.cpp
o 3358_2_LastName_FirstName_Oprional_PG7.cpp
( Section 0 )
( Section 1 )
( Section 2 )
Where LastName is your Last Name and FirstName is your First Name. For example ,
the file name should look something like :
3358_0_Gholoom_Husain_Optional_PG7.cpp ( not .cbp )
6. You must upload your programs no later than the indicated time above on the due
date. This a individual work and No late assignments will be accepted.
USE TRACS To upload your program .
7. You must also turn in hard copy of your source code no later than the due date / time
. Should the hard copy consist of more than one page , then , the hard copy must be
stapled. if you are unable to turn in a printout during class, you can take the program
to the computer science department and hand it to the front desk personal (Comal 211
) before the deadline. Make sure that the front office stamps the program. Make sure
that include the date and time. Finally ,make sure that they place the program in my
mailbox.
DO NOT slide your program under my office door – It will NOT be accepted.
Also , No late submission hard copy of the assignment will be accepted and a grade of zero
will be assigned .