Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a Java class called Heap. It will contain a PriorityQueue as its lone attribute. This PriorityQueue will simulate the heap. Your heap will keep
Create a Java class called Heap. It will contain a PriorityQueue as its lone attribute. This
PriorityQueue will simulate the heap. Your heap will keep its contents in sorted order. The
constructor to your Heap class will receive a single parameter, a String value. That String value
will be the name of a file containing words from two to six letters. Your constructor will build
the heap from those words, then use a sort method that you will write, based on the Heapsort.
Add the following methods to your Heap class:
addString : adds the specified item and then sorts the heap
removeString: removes the specified item and resorts the heap
existsString : returns a Boolean value stating whether that item is located on the heapIntention: To give the students practice working with Heaps
Description
Create a Java class called Heap. It will contain a PriorityQueue as its lone attribute. This
PriorityQueue will simulate the heap. Your heap will keep its contents in sorted order. The
constructor to your Heap class will receive a single parameter, a String value. That String value
will be the name of a file containing words from two to six letters. Your constructor will build
the heap from those words, then use a sort method that you will write, based on the Heapsort.
Add the following methods to your Heap class:
addString : adds the specified item and then sorts the heap
removeString: removes the specified item and resorts the heap
existsString : returns a Boolean value stating whether that item is located on the heap
Hand in: Submit the Java code file java for your class.
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