You will implement a heap from the following interface:
public interface Heap<V extends Comparable<V>> {
public void add(V value);
public V[] toArray(V[] array);
public V remove();
public void fromArray(V[] array);
public V[] getSortedContents(V[] array);
}
However, the Heap should be implemented as a Node Heap, that is, the internal implementation should be a tree instead of an array. The getSortedContents method should, internally, transform the heap into its array representation, and the perform Heap-Sort on it, then return the array as the result.
This prompt is kinda confusing to me. My question is what exactly is this asking me to do? I am having trouble understanding the prompt. Does it want me to just create 1 class called NodeHeap.java that implements Heap?
UPDATE: So would my NodeHeap class look something like this? or am I completely wrong
public class NodeHeap<V> implements Heap<V> {
@Override
public void add(V value) {
}
@Override
public V[] toArray(V[] array) {
return null;
}
@Override
public V remove() {
return null;
}
@Override
public void fromArray(V[] array) {
}
@Override
public V[] getSortedContents(V[] array) {
return null;
}
}'