Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Assignment

Description

Implement a class in Java named SeparateChainingHashMap containing the following methods. In our maps, we will store words made up of uppercase and lowercase English letters only. Consider the word string s0s1 sm-1 of length m, then its key will be the sum of ASCII values of its letters and its final hash value (the array index where it will be stored) is given by the function: h(k) = k mod N where N is the size of the hash table and k is the key. We will use separate chaining to handle collisions.

The nodes of the linked lists must have two separate fields - one for the key (integer) and one for the word (String). You should not use the linked list class already defined in the Java library.

1. public SeparateChainingHashMap(int N);

This constructor creates a new empty array of size N for the corresponding singly linked lists to be created after adding words to the map.

2. public int calculateKey(String word); This method returns the key of a word, not necessarily present in the map.

3. public void add(String word);

Adds a new word into the map by calculating its key and finally its hash value. Do not sort the nodes of a linked list. Simply, insert them at the end as they arrive else you may get different output.

4. public boolean remove(String word);

This method removes the word, if it is present in the map. If present, return true else return false.

5. public String remove(Integer key);

This method deletes and returns the word associated with key value key. If such an entry exists, return the word associated with the key else return null.

6. public String toString();

This method returns a human readable string representation of the hash table. To under¬stand this assume that N = 10 and a map contains three words Apple, Cat, Boy with keys 498, 280, 298 (think why?), respectively. Then System.out.println(myHashMap); where myHashMap refers to the hash map object, should print out the following:

9 (289,Cat)
1
2
3
4
5
6
7
8 (498,Apple) -> (298,Boy)
9

Unless stated, in the programs of this course you are not allowed to use any existing Java library and/or external packages for solving the problem. You should write everything from the scratch. You will receive zero i fyour program does not compile or it is found that you have copied code from some other source without any reference.

Deliverable

Upload the file SeparateChainingHashMap. java only. You are not allowed to submit any other file. Your java code should be properly indented and nicely commented. Feel free to use additional helper methods, if required.

Attachment:- Separate-Chaining-Hash-Map.java-Partial-Code.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92769992

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As