Skip to main content

Posts

Showing posts with the label The Crazy Programmer Max Heap vs Min Heap Max Heap vs Min Heap The Crazy Programmer

Max Heap vs Min Heap Vijay Sinha The Crazy Programmer

In this article, we will have a look at the difference between Max Heap and Min Heap Data Structure. We will look at the description of each data structure and examples related to them. Firstly, let us have a quick recap of the Heap Data Structure. Heap is a special type of binary tree based structure. The underlying structure resembles that of a Complete Binary Tree. As, it is a tree-based data structure all the nodes of the tree are arranged in a specific order. The tree arranges it’s nodes on the basis of a priority. Hence, it is useful to remove the highest or lowest priority element depending on the type of the heap. Typically, we represent heap using an array for faster access and space efficiency. There are mainly two types of heap: Max Heap and Min Heap . Let us have a look at the two types. Max Heap A Max Heap is basically a complete binary tree in which the Key/Data present at the Root node is greater than or equal to the data present at all of its child nodes. In other