import java lang comparable/*max-heap implementation *public class maxheapprivate [heap/pointer to the heap array private int size/maximum size of the heap private int /number of things in heap public maxheap( [hint numint maxheap hn numsize maxbuildheap()/*return current size of the heap *public int heapsize(return /*is pos leaf position*public boolean isleaf(int posreturn (pos > / &(pos )/*return position for left child of pos *public int leftchild(int posassert pos / "position has no left child"return *pos /*return position for right child of pos *public int rightchild(int posassert pos ( - )/ "position has no right child"return *pos /*return position for parent *public int parent(int posassert pos "position has no parent"return (pos- )/ /*heapify contents of heap *public void buildheap(for (int = / - >= --siftdown( )/*insert into heap *public void insert( valassert size "heap is full"int curr ++heap[currval/start at end of heap /now sift up until curr' parent' key curr' key while ((curr ! &(heap[currcompareto(heap[parent(curr)] )dsutil swap(heapcurrparent(curr))curr parent(curr)figure an implementation for the heap