Max Heap: Introduction

This lesson will give a brief introduction to Max-Heaps and how their elements are inserted or removed from Max-Heaps.

Building a Max-Heap

As mentioned in the previous lesson, max heaps follow the max heap property which means that the key at the parent node is always greater than the keys at the child nodes. Heaps can be implemented using lists or using node and tree classes. Although they are generally implemented using lists or arrays as that is the more space-efficient approach! To build a heap, start with an empty one and successively insert() all the elements.

For a visual demonstration of heap creation, check out the following illustration.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.