This is Java Programming! You need to make a BstMaxHeap.java file.   Instructions: Make a file named BstMaxHeap that will implement that implements the Driver.java and MaxHeapInterface.java. The codes are below. If you haven't looked at the code, look at them now.   Driver.java:  /**    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   MaxHeapInterface.java: /**    An interface for the ADT maxheap.        @author Frank M. Carrano    @author Timothy M. Henry    @version 5.0 */ public interface MaxHeapInterface> {    /** Adds a new entry to this heap.        @param newEntry  An object to be added. */    public void add(T newEntry);    /** Removes and returns the largest item in this heap.        @return  Either the largest object in the heap or,                 if the heap is empty before the operation, null. */    public T removeMax();    /** Retrieves the largest item in this heap.        @return  Either the largest object in the heap or,                 if the heap is empty, null. */    public T getMax();    /** Detects whether this heap is empty.        @return  True if the heap is empty, or false otherwise. */    public boolean isEmpty();    /** Gets the size of this heap.        @return  The number of entries currently in the heap. */    public int getSize();    /** Removes all entries from this heap. */    public void clear(); } // end MaxHeapInterface   This is the output we're suppsed to get after we make the BstMaxHeap file: /*  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! You need to make a BstMaxHeap.java file.

 

Instructions: Make a file named BstMaxHeap that will implement that implements the Driver.java and MaxHeapInterface.java. The codes are below. If you haven't looked at the code, look at them now.

 

Driver.java: 

/**
   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

 

MaxHeapInterface.java:

/**
   An interface for the ADT maxheap.
   
   @author Frank M. Carrano
   @author Timothy M. Henry
   @version 5.0
*/
public interface MaxHeapInterface<T extends Comparable<? super T>>
{
   /** Adds a new entry to this heap.
       @param newEntry  An object to be added. */
   public void add(T newEntry);

   /** Removes and returns the largest item in this heap.
       @return  Either the largest object in the heap or,
                if the heap is empty before the operation, null. */
   public T removeMax();

   /** Retrieves the largest item in this heap.
       @return  Either the largest object in the heap or,
                if the heap is empty, null. */
   public T getMax();

   /** Detects whether this heap is empty.
       @return  True if the heap is empty, or false otherwise. */
   public boolean isEmpty();

   /** Gets the size of this heap.
       @return  The number of entries currently in the heap. */
   public int getSize();

   /** Removes all entries from this heap. */
   public void clear();
} // end MaxHeapInterface

 

This is the output we're suppsed to get after we make the BstMaxHeap file:

/*
 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
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