Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
JawadSher authored Nov 16, 2024
1 parent 78e18ab commit af8593d
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions 19 - Heap Data Structure Problems/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<h1 align='center'>HEAP - DATA STRUCTURE - PROBLEMS</h1>

The **Heap** is a specialized tree-based data structure that satisfies the **heap property**:
- **Max-Heap**: The key of the parent node is always greater than or equal to the keys of its children.
- **Min-Heap**: The key of the parent node is always less than or equal to the keys of its children.

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.

This repository includes a variety of problems that involve:
- **Heap basics and STL implementations.**
- Common heap operations (e.g., finding kth largest/smallest elements).
- **Advanced applications** of heaps in algorithms like **merging sorted arrays**, **finding medians in a stream**, and **range problems** in multiple lists.

Each problem folder includes:
- **Problem statement and description.**
- Solutions with optimized approaches (when applicable).
- Links to the problem on **LeetCode** or **GeeksforGeeks**, along with relevant explanations.

Explore the **Heap Problems** section to gain insights into solving real-world challenges using heaps efficiently!

### Repository Content
<p>
<img src="https://img.shields.io/badge/problems%20count-04-orange?logo=leetcode" alt="LeetCode">
<img src="https://img.shields.io/badge/problems%20count-11-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks">
<img src="https://img.shields.io/badge/total%20problems%20count-17-blue" alt="Problem Count">
</p>

| **No** | **Problem Name** | **Description** | **LeetCode** | **GFG** |
| ------ | -------------------------------------------------------------- | ------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------- |
| 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 |
| 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 |
| 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) |
| 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 |
| 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) |
| 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) |
| 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) |
| 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/) |
| 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/) |
| 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) |
| 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) |
| 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) |
| 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 |
| 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) |
| 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 |
| 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) |
| 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 |

---
Happy Coding😊

0 comments on commit af8593d

Please sign in to comment.