Think about this MaxHeap: 0 1 2 3 4 5 6 23 12 19 7 10 18 14 Remember, children are found with this formula: Left child: 2i + 1 Right child: 2i + 2 Parents are found with this formula: Parent: (i - 1) / 2 If we have a maxheap, the children are smaller than the parents. If we have a minheap, the children are larger than the parents. This is a maxheap, so all parents are larger than their children. To add to a maxheap, we put the new value at the next available position in the array then swap up. In the file for your assignment, we call this process reheapUp. If we add the value 20 to the maxheap above, we get this: 0 1 2 3 4 5 6 7 23 12 19 7 10 18 14 20 We swap 20 (index 7) with its parent, if the parent is smaller. The parent value is 7 (index 3) so we swap up. 0 1 2 3 4 5 6 7 23 12 19 20 10 18 14 7 We swap 20 (index 3) with its parent, if
gadgets, technology, teaching, jobs, cameras, and other geek stuff