Answered step by step
Verified Expert Solution
Link Copied!

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:
add(String) : adds the specified item and then sorts the heap
remove(String): removes the specified item and resorts the heap
exists(String) : 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:
add(String) : adds the specified item and then sorts the heap
remove(String): removes the specified item and resorts the heap
exists(String) : returns a Boolean value stating whether that item is located on the heap
Hand in: Submit the Java code file (.java) for your class.
image text in transcribed

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

=+c) Briefly describe this distribution.

Answered: 1 week ago