Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
