Properties of Heap

Heap has the following Properties:

  • Complete Binary Tree: A heap tree is a complete binary tree, meaning all levels of the tree are fully filled except possibly the last level, which is filled from left to right. This property ensures that the tree is efficiently represented using an array.
  • Heap Property: This property ensures that the minimum (or maximum) element is always at the root of the tree according to the heap type.
  • Parent-Child Relationship: The relationship between a parent node at index ‘i’ and its children is given by the formulas: left child at index 2i+1 and right child at index 2i+2 for 0-based indexing of node numbers.
  • Efficient Insertion and Removal: Insertion and removal operations in heap trees are efficient. New elements are inserted at the next available position in the bottom-rightmost level, and the heap property is restored by comparing the element with its parent and swapping if necessary. Removal of the root element involves replacing it with the last element and heapifying down.
  • Efficient Access to Extremal Elements: The minimum or maximum element is always at the root of the heap, allowing constant-time access.

Introduction to Heap – Data Structure and Algorithm Tutorials

Similar Reads

What is Heap Data Structure?

A Heap is a special Tree-based Data Structure in which the tree is a complete binary tree....

Types of heaps:

Generally, heaps are of two types....

Properties of Heap:

Heap has the following Properties:...

Operations Supported by Heap:

Operations supported by min – heap and max – heap are same. The difference is just that min-heap contains minimum element at root of the tree and max – heap contains maximum element at the root of the tree....

Implementation of Heap Data Structure:-

The following code shows the implementation of a max-heap....

Applications of Heap Data Structure:

...

Advantages of Heaps:

...

Disadvantages of Heaps:

...

Contact Us