Question: 7 . 1 2 LAB Hashing Linear Probing Modify Main.java to implement the following linear probing exercise. The keys 1 2 , 1 8 ,

7.12 LAB Hashing Linear Probing
Modify Main.java to implement the following linear probing exercise.
The keys 12,18,13,2,3,23,5 and 15 are inserted into an initially empty hash table of length 10 using open addressing with hash function h(k)= k mod 10 and linear probing.
Modify the main() method to replace random numbers with the above eight numbers in sequence.
Input commands (Strings) are limited to "show", "insert", "delete", and "find".
Do not display the menu nor any prompt to enter a number.
Input
show exit
Output
Table: ****1213232351815
Input
insert 11 delete 5 insert 44 show find 17 exit
Output
Table: **1112132323441815 Could not find 17
Starter Code:
import java.util.Scanner;
/**
* Note: The Scanner nextInt method does not read the newline character in your input created
* by hitting "Enter," and so the call to Scanner nextLine to read (or flush) that newline.
*/
public class Main
{
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
DataItem aDataItem;
int aKey, size, n, keysPerCell;
// get sizes
System.out.print("Enter size of hash table: ");
size = scnr.nextInt();
System.out.print("Enter initial number of items: ");
n = scnr.nextInt();
keysPerCell =10;
// make table
HashTable theHashTable = new HashTable(size);
for(int j=0; j

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 Programming Questions!