
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
Concept explainers
Question
Description
Java
you will create a backend class called SortableSet. A set, in computer science, is an unordered
collection of unique objects. In our SortableSet, all of the objects in the set will also be immutable at the
set level. This means that even if the data class used to create objects is not immutable, once they are in the set they are. We do this by making a deep copy of any objects being added to the set or returned
from the set.
The objects stored in the SortableSet must implement an interface called Sortable that provides a
numeric sorting key and a deep copy method.
SortableSet also takes advantage of two custom exception classes: DuplicateException and
InvalidKeyException.
Finally, the "sortable" part of SortableSet is implemented by a getSortedList method that makes a deep
copy of every object in the set, saves them to an array, and then sorts them based on each object's
sorting key. The sort algorithm used is a recursive radix sort modified to work with objects.
Please see the attached image for details.
![Details
The overall architecture of this lab is as shown here:
Sortable Set
- set: ArrayList<Sortable>
+ add(item: Sortable): void
+ delete(key: long): void
+ update(item: Sortable): void
+ get(key: long): Sortable
+ getKeys(): long[]
+ getSorted List(): Sortable[]
- sort(a: Sortable[]); void
- sort(a: Sortable[], digit: int, numDigits: int): void
- getMaxDigits(a: Sortable[]): int
sortByDigit(a: Sortable[], digit int): void
Sortable
<<interface>>
+ getSortKey(): long
+ getDeepCopy(): Sortable
Duplicate Exception
key: long
+ Duplicate Exception(message: String, key: long)
+ getKey(): long
InvalidKeyException
- key: long
+ InvalidKeyException(message: String, key: long)
+ getKey(): long
SomeConcreteClass
someldField: long
other fields required
+ full constructor
+ getters and setters
+ to String(): String
+ getSortKey(): long
+ getDeepCopy(): Sortable
java.lang. Exception
All classes must be named as shown in the above UML
diagram except the concrete class.](https://content.bartleby.com/qna-images/question/c3acae65-05d5-4940-8762-2c9a874e450a/0d4ea900-0fe5-449b-a2af-941efc74863a/b18k2qy_thumbnail.jpeg)
Transcribed Image Text:Details
The overall architecture of this lab is as shown here:
Sortable Set
- set: ArrayList<Sortable>
+ add(item: Sortable): void
+ delete(key: long): void
+ update(item: Sortable): void
+ get(key: long): Sortable
+ getKeys(): long[]
+ getSorted List(): Sortable[]
- sort(a: Sortable[]); void
- sort(a: Sortable[], digit: int, numDigits: int): void
- getMaxDigits(a: Sortable[]): int
sortByDigit(a: Sortable[], digit int): void
Sortable
<<interface>>
+ getSortKey(): long
+ getDeepCopy(): Sortable
Duplicate Exception
key: long
+ Duplicate Exception(message: String, key: long)
+ getKey(): long
InvalidKeyException
- key: long
+ InvalidKeyException(message: String, key: long)
+ getKey(): long
SomeConcreteClass
someldField: long
other fields required
+ full constructor
+ getters and setters
+ to String(): String
+ getSortKey(): long
+ getDeepCopy(): Sortable
java.lang. Exception
All classes must be named as shown in the above UML
diagram except the concrete class.
Expert Solution

arrow_forward
Step 1 Introduction
The SortableSet class which refers to the one it is a generic class in Java that implements the Set interface. It provides a mechanism to store a collection of unique objects, where the order of the elements is determined by the Comparator or Comparable interface that is passed to the constructor. It also provides methods to add, remove, and search for elements in the set, as well as for sorting the elements in the set.
Trending nowThis is a popular solution!
Step by stepSolved in 4 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
- Data Structure & Algorithm: Describe and show by fully java coded example how a hash table works. You should test this with various array sizes and run it several times and record the execution times. At least four array sizes are recommended. 10, 15, 20, 25. It is recommended you write the classes and then demonstrate/test them using another classarrow_forwardJavaScript NOTE: Dataset is defined below. Using the data set as a pre-defined variable in your program, write code that uses the dataset to print the FIRST NAMES ONLY of people who have BOTH above average English grades AND below average age from the dataset. The solutions for the textbook examples assume you are able to export in a framework like node.js, which is why in the data set I provide, I simply set the array of objects as a variable. Your code will be in the same file (treat it like any other array variable). You can do the same with the sample files the chapter provides. For example: var ancestry = [ { .. object .. }, ...]// your code here Requirements: Cannot use any array type built-in functions except filter(), map(), and reduce(). var dataSet = [ { "name":"Maura Glass", "age":60, "math":97, "english":63, "yearsOfEducation":4 }, { "name":"James Gates", "age":55, "math":72, "english":96, "yearsOfEducation":10 }, { "name":"Mills Morris", "age":26,…arrow_forwardJAVA CODE Learning Objectives: Detailed understanding of the linked list and its implementation. Practice with inorder sorting. Practice with use of Java exceptions. Practice use of generics. You have been provided with java code for SomeList<T> class. This code is for a general linked list implementation where the elements are not ordered. For this assignment you will modify the code provided to create a SortedList<T> class that will maintain elements in a linked list in ascending order and allow the removal of objects from both the front and back. You will be required to add methods for inserting an object in order (InsertInorder) and removing an object from the front or back. You will write a test program, ListTest, that inserts 25 random integers, between 0 and 100, into the linked list resulting in an in-order list. Your code to remove an object must include the exception NoSuchElementException. Demonstrate your code by displaying the ordered linked list and…arrow_forward
- Lab 10 Using an interface to share methods It is often the case that two or more classes share a common set of methods. For programming purposes we might wish to treat the objects of those classes in a similar way by invoking some of their common routines.For example, the Dog and Cat classes listed below agree on the void method speak. Because Dog and Cat objects have the ability to “speak,” it is natural to think of putting both types of objects in an ArrayList and invoking speak on every object in the list. Is this possible? Certainly we could create an ArrayList of Dog that would hold all the Dog objects, but can we then add a Cat object to an ArrayList of Dog?Try running the main program below as it is written. Run it a second time after uncommenting the line that instantiates a Cat object and tries to add it to the ArrayList. import java.util.*;public class AnimalRunner{ public static void main(String[] args) { ArrayList<Dog> dogcatList = new ArrayList<Dog>();…arrow_forwardWritten in Python with docstring please if applicable Thank youarrow_forwardTRUE OR FALSE In order to use static methods in Collections, we must create a Collection object using a new operator.arrow_forward
- Part 2: Sorting the WorkOrders via dates Another error that will still be showing is that there is not Comparable/compareTo() method setup on the WorkOrder class file. That is something you need to fix and code. Implement the use of the Comparable interface and add the compareTo() method to the WorkOrder class. The compareTo() method will take a little work here. We are going to compare via the date of the work order. The dates of the WorkOrder are saved in a MM-DD-YYYY format. There is a dash '-' in between each part of the date. You will need to split both the current object's date and the date sent through the compareTo() parameters. You will have three things to compare against. You first need to check the year. If the years are the same value then you need to go another step to check the months, otherwise you compare them with less than or greater than and return the corresponding value. If you have to check the months it would be the same for years. If the months are the same you…arrow_forwardData Structure & Algorithm: Show by fully java coded examples how any two sorting algorithms work. You should test these with various array sizes and run them several times and record the execution times. At least four array sizes are recommended. 15, 20, 25, 30. It is recommended you write the classes and then demonstrate/test them using another class. Discuss the comparative efficiencies of your two chosen sorting algorithms.arrow_forwardJava - Gift Exchange *** Please include UML Diagram and notes in code Minimum requirements are: At least 1 loop An Array or ArrayList At least 3 Java classes Use methods I am trying to make it so that the program will: Prompt for the number of people included in exchange - If not even it will state that there has to be an even number and ask for the number of people included again (loops). Prompt to enter a participant's first name Prompt for the participant's age Print out the random matching of participants so that everyone gets a gift and everyone gives a gift. Please include UML Diagramarrow_forward
- Background Often, data are stored in a very compact but not human-friendly way. Think of how dishes in a menu can be stored in a restaurant database somewhere in the cloud. One way a dish object can be stored is this: { "name": "Margherita", "calories": 800, "price": 18.90, "is_vegetarian": "yes", "spicy_level": 2 } Obviously, this format is not user-readable, so the restaurant's frontend team produced many lines of code to render and display this content in a way that's more understandable to us, the restaurant users. We have a mini-version of the same task coming up. Given a list of similar complex objects (represented by Python dictionaries), display them in a user-friendly way that we'll define in these instructions. What is a "dish"? In this project, one dish item is a dictionary object that is guaranteed to have the following keys: "name": a string that stores the dish's name. "calories": an integer representing the calorie intake for one serving of the dish. "price": a float to…arrow_forwardJAVA programming languagearrow_forwardUse the ArrayList class Add and remove objects from an ArrayList Protect from index errors when removing Practice with input loop Details: This homework is for you to get practice adding and removing objects from an ArrayList. The Voter class was used to create instances of Voters which held their name and a voter identification number as instance variables, and the number of instances created as a static variable. This was the class diagram: The constructor takes a string, passed to the parameter n, which is the name of the voter and which should be assigned to the name instance variable. Every time a new voter is created, the static variable nVoters should be incremented. Also, every time a new voter is created, a new voterID should be constructed by concatenating the string “HI” with the value of nVoters and the length of the name. For example, if the second voter is named “Clark Kent”, then the voterID should be “HI210” because 2 is the value of nVoters and 10 is the number…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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