Question
Not looking for a full solution. Just a clue in the right direction. In Data Structures: Abstraction and Design for Java, Ed 4(Koffman & Wolfgang)
Not looking for a full solution. Just a clue in the right direction. In Data Structures: Abstraction and Design for Java, Ed 4(Koffman & Wolfgang) Ch 6 # 10 pg. The question is not entirely clear as to what to build. Is the expectation that the Heap should be implemented as a binary tree, or should it be implemented as an ArrayList? The text discusses it as an ArrayList and provides some examples however it does not show it as a binary tree other than in pictures.
- Here is the question.
Create an abstract class Heap that has two concrete subclasses, MinHeap and MaxHeap. Each subclass should have two constructors, one that takes no parameters and the other that takes a Comparator object. In the abstract class, the compare method should be abstract, and each subclass should define its own compare method to ensure that the ordering of elements corresponds to that required by the heap. For a MinHeap, the key in each node should be greater than the key of its parent; the ordering is reversed for a MaxHeap.
-Thanks
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