Draw the heap (as a binary tree) corresponding to the heap representation above as you did in Project 5.
@convention
* IS TOTAL PREORDER
and
if $this.insertionMode then $this.heapSize = 0 else $this.entries = <> and
SUBTREE_IS_HEAP($this.heap, O, $this.heapSize - 1, (relation computed by $this.machineOrder.compare method]) and O <= $this.heapSize <= |$this.heap.entries| @correspondence if $this.insertionMode then this = (true, $this.machineOrder, multiset entries($this.entries)) else this = (false, $this.machineOrder, multiset_entries($this.heap.entries(O, $this.heapSize)))
public class SortingMachine5<T> extends SortingMachineSecondary<T> {
/* Representation. */
private Comparator<T> machineOrder;
private boolean insertionMode;
private Queue<T> entries;
private Array<T> heap;
private int heapSize;
/* Rest of class removed to reduce clutter... */
}
T
Consider the following representation of a SortingMachine5<Integer> and answer the questions on the next page:
$this.machineOrder = S
$this.insertionMode = false
$this.heap = <8,12,14,19,14,17,8,5>,{0,1,2,3,4,5,6,7}
$this.entries = <>
$this.heapSize = 6