
Concept explainers
One use of a hash table is to implement a set data type. You will implement the methods addElement, find, toString, resize, and the MySetIterator inner class in the class MySet. MySet uses a separate chaining hash table to implement a set of integers. To get started, import the starter file, MySet.java into the hashset package you create in a new Java Project. Please do not change any of the method signatures in either class. Implement the methods described below. You are free to test your code however you prefer.
For additional programming practice, you can implement the union, intersect, difference methods (see the comments in the code for the desired functionality).
private void resize()
This method "doubles" the table size and reinserts the values stored in the current table. The table size should remain prime.
private boolean find(Integer e)
This method returns true if the integer e is in the set and false otherwise.
private void addElement(Integer e)
If e is not in the set, add e to the set, otherwise the set does not change. If after adding the new element numElements > 2*tableSize then call resize. This helps keep searching, inserting, and deleting into the set fast.
private String toString()
Returns a string representation for the set. The string representation of the set is { followed by a comma delimiter list of set elements followed by a }. The string for the empty set is {}. You should use the iterator you finish creating as described in the code.
public class MySetIterator {...}
Finish implementing the MySetIterator class to create an iterator for your set. This will allow you to iterate through your set when creating a String representation. See the comments in the code for more instructions.
Below is method Signature class:

Step by stepSolved in 3 steps

- Hello, I've attached the prompt for this assignment. I need help creating code to delete and update in the contactService.java according to the prompt. This is my partial code. package Contact; import java.util.ArrayList; public class ContactService {//Start with an ArrayList of contacts to hold the list of contacts ArrayList<Contact> contactList = new ArrayList<Contact>(); //Display the full list of contacts to the console for error checking. public void displayContactList() { for(int counter = 0; counter < contactList.size(); counter++) { System.out.println("\t Contact ID: " + contactList.get(counter).getContactID()); System.out.println("\t First Name: " + contactList.get(counter).getFirstName()); System.out.println("\t Last Name: " + contactList.get(counter).getLastName()); System.out.println("\t Phone Number: " + contactList.get(counter).getNumber()); System.out.println("\t Address: " +…arrow_forwardConsider an ADT list of integers. In JAVA, write a method that computes the maximum of integers in the list aList. The definition of your method should be independent of the list's implementation. Implement a method swap but remove the assumption that the ith and jth items in the list exist. Throw an exception ListIndexOutOfBoundsException if i or j is out of range.arrow_forwardWrite a generic class Students.java which has a constructor that takes three parameters – id, name, and type. Type will represent if the student is ‘remote’ or ‘in-person’. A toString() method in this class will display these details for any student. A generic method score() will be part of this class and it will be implemented by inherited classes. Write accessors and mutators for all data points. Write two classes RemoteStudents.java and InPersonStudents.java that inherits from Student class. Show the use of constructor from parent class (mind you, RemoteStudents have one additional parameter – discussion). Implement the abstract method score() of the parent class to calculate the weighted score for both types of students. Write a driver class JavaProgramming.java which has the main method. Create one remote student object and one in-person student object. The output should show prompts to enter individual scores – midterm, finals, ...... etc. and the program will…arrow_forward
- There is an error for type in ProgramNode.java. Please fix the error and show the fixed code for ProgramNode.java with the screenshot of the working code.arrow_forwardUsing eclipse, write a Console Java program that inserts 25 random integers in the range of 0 to 100 into a Linked List. (Use SecureRandom class from java.security package.SecureRandom rand = new SecureRandom(); - creates the random number objectrand.nextInt(100) - generates random integers in the 0 to 100 range)Using a ListItreator output the contents of the LinkedList in the original order. Using a ListItreator output the contents of the LinkedList in the reverse order.arrow_forwardDon't send AI generated answer or plagiarised answer. If I see these things I'll give you multiple downvotes and will report immediately.arrow_forward
- In Java, Create Movie class, which has private fields for title, director, rating. It has a constructor to initialize these fields and a toString method for printing movie details. There is also a getRating method to retrieve the movie rating. Create Rating Comparator class which implements the Comparator interface for comparing movies based on their ratings. Create DemoMovies Class. Initialize necessary data structures like LinkedList, TreeMap for rating as key and Movie from Movie class as value, TreeSet, and ProtiyQueue. Use a loop to take user input for movie detailsuntil the user enters 'WWW' as the movie title.Inside the loop, for each movie, create a Movie object, add it to various data structures that is title, director and rating based on the constructor. Add the Movie object to the LinkedList. Add the rating and the object to the TreeMap.Add the rating to the TreeSet.Add the Movie object to the Priority Queue.Display the entered movies. Sort and display Movies by rate by…arrow_forwardyou will create a simple heap data structure with several methods includingmaxHeapify and buildMaxHeap. To get started, import the starter file (Heap.java) into the heappackage you create in a new Java Project. Please do not change any of the method signatures inthe Heap class. Implement the methods described below. You are free to test your code however youprefer. Remember that arrays are indexed starting at 0 in Java. This will change the math in thepseudocode.public int parent(int i)This method should return the index of the parent of the ith element of the data array. If the ithelement is the root, then the method should return -1.public int left(int i)This method should return the index of the left child of the ith element of the data array. If the ithelement is a leaf, then the index will potentially be greater than the size of the data array. That’sfine.public int right(int i)This method should return the index of the right child of the ith element of the data array. If the…arrow_forwardYou have to use comment function to describe what each line does import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class PreferenceData { private final List<Student> students; private final List<Project> projects; private int[][] preferences; private static enum ReadState { STUDENT_MODE, PROJECT_MODE, PREFERENCE_MODE, UNKNOWN; }; public PreferenceData() { super(); this.students = new ArrayList<Student>(); this.projects = new ArrayList<Project>(); } public void addStudent(Student s) { this.students.add(s); } public void addStudent(String s) { this.addStudent(Student.createStudent(s)); } public void addProject(Project p) { this.projects.add(p); } public void addProject(String p) { this.addProject(Project.createProject(p)); } public void createPreferenceMatrix() { this.preferences = new…arrow_forward
- You will implement some methods in the UndirectedGraph class. The UndirectedGraph class contains two nested classes, Vertex and Node, you should NOT change these classes. The graph will store a list of all the vertices in the graph. Each vertex has a pointer to its adjacent vertices. To get started, import the starter file, Undirected.java into the graphs package you create in a new Java Project. Please do not change any of the method signatures in the class, but you can add any helper methods you deem necessary. Implement the methods described below. You are free to test your code however you prefer. Vertex Class (DO NOT EDIT)The vertex class holds information about the vertices in the graph. It has an int val, a Vertex next that refers to the next vertex in the list of vertices (not necessarily an adjacent vertex), and a Node edge that starts the list of adjacent vertices. Node Class (DO NOT EDIT)This is a simple class to represent an adjacency list of a vertex in the graph.…arrow_forwardPlease Code in JAVA. Type the code out neatly. Add comments . (No need for long comments). Dont add any unnecesary code or comments. Do what the attached file says. And call it a day. Thanks !arrow_forwardI ran the code and there are lots of errors in the code. Attached are images of the errors. Make sure to fix those errors and there must be no error in the code at all.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





