Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Take your class and its multiple subclasses. Read in a set of s. This set should contain some (but not all) duplicate elements. Store
Take your class and its multiple subclasses. Read in a set of s. This set should contain some (but not all) duplicate elements. Store the s in sorted order in a doubly-linked list of s based on the GDLL class from the previous homework. The sort key should have two levels. The first level should be a identifier and the second key should be something else. You may modify the GDLL class as you see fit to help you do this. If you run across an in the set you read from, and that is already in the doubly-linked list, delete that before going on to add/delete later s. Print the doubly-linked list after each addition and deletion. Details: Your input file should be either entered from your main program or a separate text file. I will test with your file in the order you have the s, and I will also permute your inputs to see that it still works. You need to have at least three elements of each subclass in this file/test method. They should not be in sorted order already. Use insertion sort, and sort by moving Nodes containing objects on the linked list. I don't care if you sort high to low or low to high or by some other method. Explain your sort criteria in your compareTo(...) method documentation. When I say that two objects are equal, I mean that they have the same subtype and values of all attributes. I do not mean that they are in the same memory location (so you need to write an equals (...) method). Describe your sort key in comments of the header of the compareTo(...) method. Grading: This program is worth 40 points. 10 points for proper Comparable interface usage and compareTo(...) code 10 points for proper doubly linked list code (including Node class code) 10 points for proper insertion sort 10 points for proper deletion
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started