Question
Java language using Priority interface provided below A class DWayHeap that implements a d-heap where d is the number of children for nonleaf nodes. Your
Java language using Priority interface provided below
A class DWayHeap that implements a d-heap where d is the number of children for nonleaf nodes. Your class should implement the same priority queue interface and it should use a contiguous array portion as in your first implementation. It should include an empty constructor and additional constructor that takes d as an argument, work correctly for any d greater than or equal to 2, and use d as the number of children for nodes.
priority queue interface:
/** * Base interface for priority queue implementations for doubles. Throw * exceptions as appropriate. */ public interface PriorityQueue { /** * Returns true if priority queue has no elements * * @return true if the priority queue has no elements */ public boolean isEmpty();
/** * Returns the number of elements in this priority queue. * * @return the number of elements in this priority queue. */ public int size();
/** * Returns the minimum element in the priority queue * * @return the minimum element * @throws EmptyPQException * if priority queue contains no elements */ public double findMin();
/** * Inserts a new element into the priority queue. Duplicate values ARE * allowed. * * @param x * element to be inserted into the priority queue. */ public void insert(double x);
/** * Removes and returns the minimum element from the priority queue. * * @return the minimum element * @throws EmptyPQException * if priority queue contains no elements */ public double deleteMin();
/** * Resets the priority queue to appear as not containing any elements. */ public void makeEmpty();
}
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