Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
10.5 LAB: Implementing StaticSet using HashSet
Java HashSet overview
The java.util package contains a HashSet class that implements a dynamic set. Functionality is described in online documentation.
Step 1: Inspect StaticSet.java
Inspect the StaticSet generic class declaration in the StaticSet.java file. Access StaticSet.java by clicking on the orange arrow next to LabProgram.java at the top of the coding window. StaticSet uses a HashSet to implement a static set. The HashSet's contents are assigned at construction time and must not change after.
Constructors and some additional methods are already implemented:
contains(T item) uses the HashSet's contains() method to determine if the set contains the item. If contains() returns true, the item is in the set. Otherwise the item is not in the set and contains() returns false.
getSize() uses the HashSet's size() method to determine the number of elements in the set. getSize() returns the set's size.
Step 2: Implement StaticSet's union(), intersection(), difference(), filter(), and map() methods
Implement the StaticSet class's union(), intersection(), difference(), filter(), and map() methods. Each must not change the StaticSet itself, but rather build and return a new StaticSet.
Step 3: Test in develop mode, then submit
File LabProgram.java contains test cases for each of the five operations. Running code in develop mode displays the test results, with 3 points possible for the union(), intersection(), and difference() operations, and 2 points for the filter() and map() operations. After each method is implemented and all tests pass in develop mode, submit the code. The unit tests run on submitted code are similar, but use different sets and generic types.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 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 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_forwardProgram #11. Show the ArrayStackADT interface 2. Create the ArrayStackDataStrucClass<T> with the following methods: default constructor, overloaded constructor, copy constructor, initializeStack, isEmptyStack, isFullStack, push, peek, void pop 3. Create the PrimeFactorizationDemoClass: instantiate an ArrayStackDataStrucClass<Integer> object with 50 elements. Use a try-catch block in the main( ) using pushes/pops. 4. Exception classes: StackException, StackUnderflowException, StackOverflowException 5. Show the 4 outputs for the following: 3,960 1,234 222,222 13,780arrow_forward
- Design a class that acquires the JSON string from question #1 and converts it to a class data member dictionary. Your class produces data sorted by key or value but not both. Provide searching by key capabilities to your class. Provide string functionality to convert the dictionary back into a JSON string. question #1: import requestsfrom bs4 import BeautifulSoupimport json class WebScraping: def __init__(self,url): self.url = url self.response = requests.get(self.url) self.soup = BeautifulSoup(self.response.text, 'html.parser') def extract_data(self): data = [] lines = self.response.text.splitlines()[57:] # Skip the first 57 lines for line in lines: if line.startswith('#'): # Skip comment lines continue values = line.split() row = { 'year': int(values[0]), 'month': int(values[1]), 'decimal_date': float(values[2]),…arrow_forward11.8 At what point does the Java environment complain about your passinga non-Comparable value to an OrderedVector?11.9 Write the compareTo method for the String class.11.10 Write the compareTo method for a class that is to be ordered by a field,key, which is a double. Be careful: The result of compareTo must be an int.arrow_forwardCreate the Singly Linked List after having executed the following methods. Each item must have a headand tailreference. Whenever a method is not expected or invalid, write Exception. Only the process not the code •addHead("Dancing") •addHead("Backup") •addHead("Backup") •addTail("Backup") •addTail("Backup") •removeHead()arrow_forward
- a) Create a HeapPriorityQueue interface with the following abstract methods: isEmpty, is Full, enqueue, dequeue, reheapifyUpward, reheapify Downward, reposition. b) Create the HeapPriorityQueue class. Have heapArray hold maxSize of 250 entries. Also, include the methods: default constructor, toString. c) Create HeapOverflowException and HeapUnderflowException classes d) Create a Heap Demo class that creates a HeapPriorityQueue object and insert the values 1-10 into the heap. Print out the heap and remove two values from the heap. Print the resulting heap. Try and show the resulting tree with the nodes on their appropriate levels along with their branches.arrow_forward3.25 Fixed Sized Deque Your task is to create an implementation of the Java Deque interface that can only hold N items where N is a number passed into the constructor. Note that most (if not all) of the unit tests rely on the method object[] toArray() inherited from Collection. Therefore, you must make sure you implement that method correctly in order to get most of the points. 301664.1524810.gpazay7 LAB АCTIVITY 3.25.1: Fixed Sized Deque 0/ 70 Submission Instructions Compile command javac FixedsizedDeque.java -xlint:all -encoding utf-8 We will use this command to compile your code Upload your files below by dragging and dropping into the area or choosing a file on your hard drive. FixedSizedDeque.java Drag file here or Choose on hard drive.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education