Implement a class in java named separatechaininghashmap

Assignment Help JAVA Programming
Reference no: EM131931335

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

Reference no: EM131931335

Questions Cloud

What is the real rate of return on this investment : The current inflation rate is 3% per year. What is the real rate of return on this investment?
What is meant by different people relate differently : What is meant by different people relate differently towards taking risks that may hasten death? Give an example of such risks. Make it 4-5 lines in response.
What is the cash conversion cycle of the firm : ABC, Inc. has been experiencing cash shortages due to its high growth rate. Using the following information, what is the firm's Cash Conversion Cycle?
Which of the following is not a type of business entity : The covenant of quiet enjoyment requires a landlord to leave the tenant undisturbed in the tenants enjoyment of the property.
Implement a class in java named separatechaininghashmap : Implement a class in Java named SeparateChainingHashMap containing the following methods. We will use separate chaining to handle collisions.
Statistical information as evidence to support our claim : What are some things we need to consider before including statistical information as evidence to support our claim?
Create a database and import the four text files : CIS1000 Database Management System (DBMS) & Decision Support System (DSS) Assignment. Create a Database and import the four (4) Text files into four (4) Tables
Compute the total shortage costs : ABC Company sells 2, 052 chairs a year at an average price per chair of $154. The carrying cost per unit is $18.79. The company orders 259 chairs at a time.
Turn of the screw and the movie the innocents : What are the major differences between the book The turn of the screw and the movie the innocents?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd