Skip to content

Commit af8593d

Browse files
authored
Create README.md
1 parent 78e18ab commit af8593d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h1 align='center'>HEAP - DATA STRUCTURE - PROBLEMS</h1>
2+
3+
The **Heap** is a specialized tree-based data structure that satisfies the **heap property**:
4+
- **Max-Heap**: The key of the parent node is always greater than or equal to the keys of its children.
5+
- **Min-Heap**: The key of the parent node is always less than or equal to the keys of its children.
6+
7+
Heaps are primarily used in scenarios requiring **priority queues**, **sorting algorithms** (e.g., heap sort), and **efficient retrieval of minimum or maximum elements**. Due to their structure, heaps are highly efficient for operations like inserting, deleting, or finding elements in \( O(\log n) \) time.
8+
9+
This repository includes a variety of problems that involve:
10+
- **Heap basics and STL implementations.**
11+
- Common heap operations (e.g., finding kth largest/smallest elements).
12+
- **Advanced applications** of heaps in algorithms like **merging sorted arrays**, **finding medians in a stream**, and **range problems** in multiple lists.
13+
14+
Each problem folder includes:
15+
- **Problem statement and description.**
16+
- Solutions with optimized approaches (when applicable).
17+
- Links to the problem on **LeetCode** or **GeeksforGeeks**, along with relevant explanations.
18+
19+
Explore the **Heap Problems** section to gain insights into solving real-world challenges using heaps efficiently!
20+
21+
### Repository Content
22+
<p>
23+
<img src="https://img.shields.io/badge/problems%20count-04-orange?logo=leetcode" alt="LeetCode">
24+
<img src="https://img.shields.io/badge/problems%20count-11-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks">
25+
<img src="https://img.shields.io/badge/total%20problems%20count-17-blue" alt="Problem Count">
26+
</p>
27+
28+
| **No** | **Problem Name** | **Description** | **LeetCode** | **GFG** |
29+
| ------ | -------------------------------------------------------------- | ------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------- |
30+
| 01 | [Example](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/01%20-%20Example) | Basic heap operations. | Non | Non |
31+
| 02 | [Example - STL](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/02%20-%20Example%20-%20STL) | Demonstration of heap operations using STL. | Non | Non |
32+
| 03 | [Kth Smallest](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/03%20-%20Kth%20Smallest) | Find the kth smallest element in an array. | Non | [Link](https://www.geeksforgeeks.org/problems/kth-smallest-element5635/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
33+
| 04 | [Check Completeness of a Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/04%20-%20Check%20Completeness%20of%20a%20Binary%20Tree) | Verify if a binary tree is complete. | [Link](https://leetcode.com/problems/check-completeness-of-a-binary-tree/) | Non |
34+
| 05 | [Is Binary Tree Heap](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/05%20-%20Is%20Binary%20Tree%20Heap) | Determine if a binary tree satisfies heap property. | Non | [Link](https://www.geeksforgeeks.org/problems/is-binary-tree-heap/1) |
35+
| 06 | [Merge Two Binary Max Heaps](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/06%20-%20Merge%20Two%20Binary%20Max%20Heaps) | Merge two max heaps into one. | Non | [Link](https://www.geeksforgeeks.org/problems/merge-two-binary-max-heap0144/1) |
36+
| 07 | [Minimum Cost of Ropes](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/07%20-%20Minimum%20Cost%20of%20Ropes) | Find the minimum cost of connecting ropes. | Non | [Link](https://www.geeksforgeeks.org/problems/minimum-cost-of-ropes-1587115620/1) |
37+
| 08 | [Convert BST to Min Heap](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/08%20-%20Convert%20BST%20to%20Min%20Heap) | Convert a binary search tree to a min-heap. | Non | [Link](https://www.geeksforgeeks.org/convert-bst-min-heap/) |
38+
| 09 | [Convert BST to Max Heap](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/09%20-%20Convert%20BST%20to%20Max%20Heap) | Convert a binary search tree to a max-heap. | Non | [Link](https://www.geeksforgeeks.org/convert-bst-to-max-heap/) |
39+
| 10 | [BST to Max Heap](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/10%20-%20BST%20to%20Max%20Heap) | Another approach to convert BST to max-heap. | Non | [Link](https://www.geeksforgeeks.org/problems/bst-to-max-heap/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
40+
| 11 | [Kth Largest Sum Contiguous Subarray](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/11%20-%20Kth%20Largest%20Sum%20Contiguous%20Subarray) | Find the kth largest sum in contiguous subarrays. | Non | [Link](https://www.geeksforgeeks.org/problems/k-th-largest-sum-contiguous-subarray/1) |
41+
| 12 | [Merge K Sorted Arrays](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/12%20-%20Merge%20K%20Sorted%20Arrays) | Merge k sorted arrays into a single sorted array. | Non | [Link](https://www.geeksforgeeks.org/problems/merge-k-sorted-arrays/1) |
42+
| 13 | [Merge K Sorted Lists](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/13%20-%20Merge%20K%20Sorted%20Lists) | Merge k sorted linked lists into a single sorted list. | [Link](https://leetcode.com/problems/merge-k-sorted-lists/) | Non |
43+
| 14 | [Smallest Range in K Lists](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/14%20-%20Smallest%20Range%20in%20K%20Lists) | Find the smallest range that includes elements from k lists. | Non | [Link](https://www.geeksforgeeks.org/problems/find-smallest-range-containing-elements-from-k-lists/1) |
44+
| 15 | [Smallest Range Covering Element from K Lists](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/15%20-%20Smallest%20Range%20Covering%20Element%20from%20K%20Lists) | Find the smallest range in k lists covering all elements.| [Link](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/) | Non |
45+
| 16 | [Find Median in a Stream](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/16%20-%20Find%20Median%20in%20a%20Stream) | Compute the median dynamically in a stream of numbers. | Non | [Link](https://www.geeksforgeeks.org/problems/find-median-in-a-stream-1587115620/1) |
46+
| 17 | [Find Median From Data Stream](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/19%20-%20Heap%20Data%20Structure%20Problems/17%20-%20Find%20Median%20From%20Data%20Stream) | Calculate the median from a continuous data stream. | [Link](https://leetcode.com/problems/find-median-from-data-stream/) | Non |
47+
48+
---
49+
Happy Coding😊

0 commit comments

Comments
 (0)