ICS4U ACES: Heap Example |
To warm you up for tonight's submission (Ternary Cantor Set), you are asked to generate the Heap depicted below, left. Recall from our previous class that a Heap is an array representation of a non-linked binary tree.
In this example, the green numbers represent the contents of the array cells and the red numbers, the array indices. Each node in the Heap is a power of 2, with it's children, one degree less.
Create a project called HeapTest and drop in this driver. Complete the body of the recursive makeHeap(int node, int i) method, making maximum use of Java's integral bit shift operators: << and >> to populate the object instance field: heap.
Heap Model | Output |
---|---|