Heaps are typically implemented with a data structure such as an array or Python list. These sequential structures allow access to elements in a particular order which is key to efficient use of heaps. Although binary trees are helpful for understanding the relationships between nodes of a heap, implementation using a tree is less efficient for storage and retrieval of elements.
- 4Great work so far! Our MinHeap adds elements to the internal list, keeps a running count, and has the beginnings of .heapify_up(). Before we dive into the logic for .heapify_up(), let’s review how…