Min Heap vs. Max Heap

Min and Max heaps are complete binary trees with some unique properties.

Binary Tree

A Binary Tree is a tree data structure wherein each node has at most two “children.”

A node in the binary tree typically contains the following properties:

  • Reference to the left child.
  • Reference to the right child.
  • Data

A complete Binary Tree is a binary tree in which every level, except possibly the last, is filled.

svg viewer

Min-Heap

  • The root node has the minimum value.

  • The value of each node is equal to or greater than the value of its parent node.

  • A complete binary tree.

Max-Heap

  • The root node has the maximum value.

  • The value of each node is equal to or less than the value of its parent node.

  • A complete binary tree.