Add animated operations to the basic Heap VisualizationApp
visualizing just the array representation of the heap. We'll add the
tree visualization separately.
Implement animated methods for:
Peek
Remove Max
Random Fill
Heapify
Peek should copy the first element of the array to the bottom of the
canvas, like the Traverse operation in Array.py. The value should be
labeled "Root". The Remove Max should also animate copying the first
element of the array to the Root result, and then animate the process
of moving the last element to the first element of the array, reducing
nItems, and then sifting the first item down.
Random Fill should take a number, 1-31, as an argument, create an
array of that size, fill it with random numbers in the range 0-99, and
place the nItems at 1 to indicate only the first item in the array
meets the heap condition. The Heapify button should only be enabled
when the number of items in the array exceeds nItems. When Heapify
is run it organizes the items in the array into a heap using sift down
and finishes by setting nItems to include all the items in the array
(disabling the Heapify button).
Add animated operations to the basic Heap VisualizationApp visualizing just the array representation of the heap. We'll add the tree visualization separately.
Implement animated methods for:
Peek should copy the first element of the array to the bottom of the canvas, like the Traverse operation in Array.py. The value should be labeled "Root". The Remove Max should also animate copying the first element of the array to the Root result, and then animate the process of moving the last element to the first element of the array, reducing
nItems
, and then sifting the first item down.Random Fill should take a number, 1-31, as an argument, create an array of that size, fill it with random numbers in the range 0-99, and place the
nItems
at 1 to indicate only the first item in the array meets the heap condition. The Heapify button should only be enabled when the number of items in the array exceedsnItems
. When Heapify is run it organizes the items in the array into a heap using sift down and finishes by setting nItems to include all the items in the array (disabling the Heapify button).