Question: Make a Java program, based on ChainedTable.java (provided at the bottom), that uses chained hashing and has the methods described below. a. Complete the put

Make a Java program, based on ChainedTable.java (provided at the bottom), that uses chained hashing and has the methods described below.

a. Complete the put method to set the cursor to refer to the node that already contains the specified node. If there is no such node, then cursor should be set to null. NOTE: You are allowed to copy the solution given to Self-Test Exercise #12 (given at the bottom).

b. Add a public print method that prints the table indexes followed by all (key,element) pairs. Note that the sample code in ChainedTable.java adds new nodes at the beginning of the linked list. This means the first insertion in a list will be printed last. Below is an example using print() with an array capacity of 4 and using put(1, Hi) and put(4, Bye).

Make a Java program, based on ChainedTable.java (provided at the bottom), that

c. Provide a main method that demonstrates the methods from (a) and (b). Provide example output.

Self-Test Exercise #12 Solution:

uses chained hashing and has the methods described below. a. Complete the

ChainedTable.java:

public class ChainedTable { private ChainedHashNode[ ] table; public ChainedTable(int tableSize) { if (tableSize   [1] 12] (4, Bye) (1, Hi) public ChainedHashNode findNodeCObject key) ChainedHashNode cursor cursor table[hash(key)] while (cursor-null) if (key.equals(cursor.key) return cursor cursorcursor.link; return nu11;  [1] 12] (4, Bye) (1, Hi) public ChainedHashNode findNodeCObject key) ChainedHashNode cursor cursor table[hash(key)] while (cursor-null) if (key.equals(cursor.key) return cursor cursorcursor.link; return nu11

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