Create a Heap class based on VisualizationApp using the code
from Max_Heap.py. Heaps are represented in arrays but are typically
drawn as binary trees. A BinaryTreeBase class is being built separately
so this initial task is to visualize just the array representation
of the heap. We'll add the tree visualization separately.
The heap will have the maximum value at the root. Items inserted
should be limited to integers in the range 0-99.
Rename Max_Heap.py as Heap.py and implement the animated methods for:
New Heap (empty but with 2 array cells)
Insert
Show the array representation as a vertical array on the left side of
the canvas, with the root at the top. Use smaller cells and fonts to
keep this visualization small and leave room for a binary tree on the
right. Make the cells small enough to fit 31 of them on the canvas
with some buffer above and below. Include a nItems pointer that
shows the number of items in the heap, pointing at array index 0 for
an empty heap. The heap grows as items are added, doubling in size
when an insertion is made that would go beyond the current size.
Animate the growth of the array by moving the current vertical array
to the right, creating a new empty array to its left that's twice as
long as the current array, copying the individual values over to the
new array, and erasing the old array.
Create a Heap class based on VisualizationApp using the code from Max_Heap.py. Heaps are represented in arrays but are typically drawn as binary trees. A BinaryTreeBase class is being built separately so this initial task is to visualize just the array representation of the heap. We'll add the tree visualization separately.
The heap will have the maximum value at the root. Items inserted should be limited to integers in the range 0-99. Rename Max_Heap.py as Heap.py and implement the animated methods for:
Show the array representation as a vertical array on the left side of the canvas, with the root at the top. Use smaller cells and fonts to keep this visualization small and leave room for a binary tree on the right. Make the cells small enough to fit 31 of them on the canvas with some buffer above and below. Include a
nItems
pointer that shows the number of items in the heap, pointing at array index 0 for an empty heap. The heap grows as items are added, doubling in size when an insertion is made that would go beyond the current size. Animate the growth of the array by moving the current vertical array to the right, creating a new empty array to its left that's twice as long as the current array, copying the individual values over to the new array, and erasing the old array.Remove the Min_Heap.py file from the repo.