Image for post
Image for post
Both trees are complete, but the BST is also full

At first glance, one might not be able to distinguish between the two trees above, because you know, they all look similar. However, on getting a closer look, the nodes seem to be ordered in some logical way. In the figure above, the tree on the left is a Binary Search Tree and the one on the right is a Binary Heap, specifically a Min Heap. Both of them are binary trees, but each follows a different set of rules.

A binary heap is simply a binary tree that obeys the following rules -

  • The tree must be complete —…

Amal Krishna

I write something when I get a burst of inspiration, about once in a blue moon.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store