Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

do this in java Project Description. A generic ADT Priority queue can be designed and implemented with a generic ADT heap, another abstract data type.

do this in java
image text in transcribed
image text in transcribed
Project Description. A generic ADT Priority queue can be designed and implemented with a generic ADT heap, another abstract data type. In this project, you are required to design a generic ADT heap that uses an array list, as the data structure, to store a list of objects, in this project, consider the Employee. Each employee contains two unique values: 1) name : a full name in a format as in "JohnSmith". 2) pay rate: a numeric value indicating the annual income of an employee. Assume we store a list of employees using an ADT priority queue according to their names or their pay rates. Therefore, we need to create two comparators. A name comparator: compares/sorts employees by their names. A pay rate comparator: compares/sorts employees by their pay rates. To organize employees in a priority queue, we first create an empty priority queue with a reference to a comparator passed into the constructor as the ordering for the queue (more accurately for the heap that is used to implement the queue). And then, insert the employees into the queue according to their priority defined in the comparator. If the comparator compares employee names, the name in the root of a heap is greater than the names of its children. If the comparator compares employee pay rates, the pay rate in the root of a heap is greater than the pay rates of its children. To use Employee to test this project, we need to design three classes. Employee .A name comparator for employee, a class implementing the interface java.util.Comparator. A pay rate comparator for employee, a class implementing the interface java.util.Comparator. Remember, It is not allowed to use any other Java ADTs/JFC Collection types in the java library. A generic ADT Priority Queue contains a reference to a generic ADT Heap. A generic ADT Heap should contain the following operations. When designing a method, you should consider all possible exceptions. insert: inserts an item into a heap. delete: retrieves and removes the item in the root of a heap. heapify: rebuild a heap if the root is not a leaf and the root's priority/key is less than the larger of the keys of the root's children. isEmpty: determines if a heap is empty. sort: sorts the items in a heap using the Heap Sort algorithm. When implementing the generic ADT Heap, two attributes should be included. an array list must be used as data structure. It is not allowed to use any other Java ADTs/JFC Collection types in the java library A reference to a comparator specifying the ordering used for organizing a list of objects in a heap. A generic ADT Priority Queue contains a reference to a generic ADT Heap and execute most of the following operations in the heap. When designing a method, you should consider all possible exceptions. insert: inserts an item into a heap. This method should invoke insert of the heap. delete: retrieves and removes the item in the root of a heap. This method should invoke delete of the heap. isEmpty: determines if the heap is empty. This method should invoke isEmpty of the heap. sort: sorts the items in the heap using the Heap Sort algorithm. This method should invoke sort of the heap

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago