Heap Data Structure
Last Updated :
11 Dec, 2024
Improve
A Heap is a complete binary tree data structure that satisfies the heap property: for every node, the value of its children is greater than or equal to its own value. Heaps are usually used to implement priority queues, where the smallest (or largest) element is always at the root of the tree.
Basics
Library Implementations
Easy Problems
- Heap Sort
- Check if Binary Tree is Heap
- Check if an array is Heap?
- Iterative Heap Sort
- K’th Largest Element
- Height of a complete binary tree (or Heap) with N nodes
- Heap Sort for Decreasing Order
Medium Problems
- Nearly Sorted Array
- K Largest Elements & K Smallest
- K’th Smallest & K'th Largest
- Huffman Coding
- Nodes less than a value in a Min Heap.
- Tournament Tree and Binary Heap
- Connect n ropes with minimum cost
- Maximum distincts after removing k elements
- K maximum sum combinations from two arrays
- Median in a stream
- K’th largest in a stream
- Largest triplet product in a stream
- k most frequent
- Min Heap to Max Heap
- Check for Min-Heap from Level Order
Hard Problems
- Design a data structure with min and max operations
- Merge k sorted arrays
- Merge K Sorted Linked Lists
- Prim's Minimum Spanning Tree
- Dijkstra's Shortest Path
- Sort numbers stored on different machines
- Smallest Derangement of Sequence
- Largest Derangement of a Sequence
- Maximum difference between two subsets of m elements
- Convert BST to Min Heap
- Merge two binary Max Heaps
- K-th Largest Sum Contiguous Subarray
- Minimum product of k integers
- Leaf starting point in a Binary Heap data structure
- Rearrange characters in a string such that no two adjacent are same
- Sum of all elements between k1’th and k2’th smallest elements
- Minimum sum of two numbers formed from digits of an array
Other Types of Heaps
Quick Links:
Recommended:


