This is Java Programming! We are working with MaxHeap   Instructions: Don't modify the two codes below. You need to make a MaxHeapInterface.java that implements the bstMaxHeap in the Driver.java code. If you haven't look at the code, look at them now.   Driver.java code: /**   A driver that demonstrates the class BstMaxHeap.      @author Frank M. Carrano   @author Timothy M. Henry   @version 5.0 */ public class Driver  { public static void main(String[] args)  {  String jared    = "Jared";  String brittany = "Brittany";  String brett    = "Brett";  String doug     = "Doug";  String megan    = "Megan";  String jim      = "Jim";  String whitney  = "Whitney";  String matt     = "Matt";  String regis    = "Regis";    MaxHeapInterface aHeap = new BstMaxHeap<>();  aHeap.add(jared);    aHeap.add(brittany);  aHeap.add(brett);  aHeap.add(doug);    aHeap.add(megan);  aHeap.add(jim);  aHeap.add(whitney);    aHeap.add(matt);  aHeap.add(regis);    if (aHeap.isEmpty())   System.out.println("The heap is empty - INCORRECT");  else   System.out.println("The heap is not empty; it contains " +                      aHeap.getSize() + " entries.");    System.out.println("The largest entry is " + aHeap.getMax());    System.out.println("\n\nRemoving entries in descending order:");  while (!aHeap.isEmpty())   System.out.println("Removing " + aHeap.removeMax());     System.out.println("\n\nTesting constructor with array parameter:\n");  String[] nameArray = {jared, brittany, brett, doug, megan,                         jim, whitney, matt, regis};  MaxHeapInterface anotherHeap = new BstMaxHeap<>(nameArray);    if (anotherHeap.isEmpty())   System.out.println("The heap is empty - INCORRECT");  else   System.out.println("The heap is not empty; it contains " +                      anotherHeap.getSize() + " entries.");    System.out.println("The largest entry is " + anotherHeap.getMax());    System.out.println("\n\nRemoving entries in descending order:");  while (!anotherHeap.isEmpty())   System.out.println("Removing " + anotherHeap.removeMax()); }  // end main }  // end Driver   HERE IS THE OUTPUT WE'RE SUPPOSED TO GET AFTER WE MAKE THE MAXHEAPINTERFACE CODE: /* The heap is not empty; it contains 9 entries. The largest entry is Whitney Removing entries in descending order: Removing Whitney Removing Regis Removing Megan Removing Matt Removing Jim Removing Jared Removing Doug Removing Brittany Removing Brett Testing constructor with array parameter: The heap is not empty; it contains 9 entries. The largest entry is Whitney Removing entries in descending order: Removing Whitney Removing Regis Removing Megan Removing Matt Removing Jim Removing Jared Removing Doug Removing Brittany */

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is Java Programming! We are working with MaxHeap

 

Instructions: Don't modify the two codes below. You need to make a MaxHeapInterface.java that implements the bstMaxHeap in the Driver.java code. If you haven't look at the code, look at them now.

 

Driver.java code:

/**
  A driver that demonstrates the class BstMaxHeap.
  
  @author Frank M. Carrano
  @author Timothy M. Henry
  @version 5.0
*/
public class Driver 
{
public static void main(String[] args) 
{
 String jared    = "Jared";
 String brittany = "Brittany";
 String brett    = "Brett";
 String doug     = "Doug";
 String megan    = "Megan";
 String jim      = "Jim";
 String whitney  = "Whitney";
 String matt     = "Matt";
 String regis    = "Regis";
 
 MaxHeapInterface<String> aHeap = new BstMaxHeap<>();
 aHeap.add(jared);  
 aHeap.add(brittany);
 aHeap.add(brett);
 aHeap.add(doug);  
 aHeap.add(megan);
 aHeap.add(jim);
 aHeap.add(whitney);  
 aHeap.add(matt);
 aHeap.add(regis);
 
 if (aHeap.isEmpty())
  System.out.println("The heap is empty - INCORRECT");
 else
  System.out.println("The heap is not empty; it contains " +
                     aHeap.getSize() + " entries.");
 
 System.out.println("The largest entry is " + aHeap.getMax());
 
 System.out.println("\n\nRemoving entries in descending order:");
 while (!aHeap.isEmpty())
  System.out.println("Removing " + aHeap.removeMax());

  
 System.out.println("\n\nTesting constructor with array parameter:\n");
 String[] nameArray = {jared, brittany, brett, doug, megan, 
                       jim, whitney, matt, regis};
 MaxHeapInterface<String> anotherHeap = new BstMaxHeap<>(nameArray);
 
 if (anotherHeap.isEmpty())
  System.out.println("The heap is empty - INCORRECT");
 else
  System.out.println("The heap is not empty; it contains " +
                     anotherHeap.getSize() + " entries.");
 
 System.out.println("The largest entry is " + anotherHeap.getMax());
 
 System.out.println("\n\nRemoving entries in descending order:");
 while (!anotherHeap.isEmpty())
  System.out.println("Removing " + anotherHeap.removeMax());
}  // end main
}  // end Driver

 

HERE IS THE OUTPUT WE'RE SUPPOSED TO GET AFTER WE MAKE THE MAXHEAPINTERFACE CODE:

/*
The heap is not empty; it contains 9 entries.
The largest entry is Whitney


Removing entries in descending order:
Removing Whitney
Removing Regis
Removing Megan
Removing Matt
Removing Jim
Removing Jared
Removing Doug
Removing Brittany
Removing Brett


Testing constructor with array parameter:

The heap is not empty; it contains 9 entries.
The largest entry is Whitney


Removing entries in descending order:
Removing Whitney
Removing Regis
Removing Megan
Removing Matt
Removing Jim
Removing Jared
Removing Doug
Removing Brittany
*/

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education