Heap

In the lesson, we'll discuss heap, a very useful tree-based data structure.

We'll cover the following

Structure

Heap is a complete binary tree. There are two types of heaps

  • Min Heap
  • Max Heap

Min heap

In min-heap, each node is smaller than its children. This means the root has the smallest key among all the nodes. Similarly, the left child of the root is the smallest among all nodes in the left subtree of the root, and so on.

Similarly, in a max heap, the key for each node is greater than both its children.

Get hands-on with 1200+ tech skills courses.