Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

image text in transcribed

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

Self-Test Exercise #12 Solution:

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago