The Wayback Machine - https://web.archive.org/web/20240126141749/https://www.geeksforgeeks.org/heap-data-structure/
Open In App
Related Articles

Heap Data Structure

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Learn Data Structures and Algorithms | DSA Tutorial
Learn more about Heap in DSA Self Paced Course
Practice Problems on Heap
Top Quizzes on Heap

What is Heap Data Structure?

A Heap is a special Tree-based data structure in which the tree is a complete binary tree.

Heap Data Structure

Operations of Heap Data Structure:

  • Heapify: a process of creating a heap from an array.
  • Insertion: process to insert an element in existing heap time complexity O(log N).
  • Deletion: deleting the top element of the heap or the highest priority element, and then organizing the heap and returning the element with time complexity O(log N).
  • Peek: to check or find the first (or can say the top) element of the heap.

Types of Heap Data Structure

Generally, Heaps can be of two types:

  1. Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of it’s children. The same property must be recursively true for all sub-trees in that Binary Tree.
  2. Min-Heap: In a Min-Heap the key present at the root node must be minimum among the keys present at all of it’s children. The same property must be recursively true for all sub-trees in that Binary Tree.

Introduction to Heap Data Structure:

Some other types of Heap Data Structure:

Standard Easy Problems on Heap Data Structure:

Standard Medium Problems on Heap Data Structure:

Standard Hard Problems on Heap Data Structure:

Quick Links:

Recommended:


Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!


Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 24 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials