[PR #1526] feat(data-structure): Add Min Binary Heap implementation in C #2140

Open
opened 2026-01-29 15:29:24 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/TheAlgorithms/C/pull/1526

State: closed
Merged: No


Fixes #1497

Description of Change

This Pull Request introduces a complete implementation of a Min Binary Heap data structure in C, utilizing dynamic array representation and proper memory management (malloc/free).

The file is located at data_structures/binary_tree_in_c/Min Binary Heap.c.

Implementation Details
Memory Management:** Dynamic allocation for the underlying array and heap structure.
Core Logic:** Implements heapify_up (for insertion) and heapify_down (for extraction) to maintain the Min Heap property.
Demonstration:** Includes a main() function demonstrating all operations and memory cleanup.

⚙️ Supported Operations & Complexity

Operation Time Complexity
Insert O(\log n)
Extract Min O(\log n)
Get Min (Peek) O(1)
Search O(n)
Display O(n)

References

No specific external references needed.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass (Included in the main function)
  • Relevant documentation/comments is changed or added (Added extensive function documentation and header comments)
  • PR title follows semantic commit guidelines (The title should be feat(data-structure): Add Min Binary Heap implementation in C)
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Implements the requested Min Binary Heap data structure.

**Original Pull Request:** https://github.com/TheAlgorithms/C/pull/1526 **State:** closed **Merged:** No --- Fixes #1497 #### Description of Change This Pull Request introduces a complete implementation of a **Min Binary Heap** data structure in C, utilizing dynamic array representation and proper memory management (`malloc/free`). The file is located at `data_structures/binary_tree_in_c/Min Binary Heap.c`. Implementation Details Memory Management:** Dynamic allocation for the underlying array and heap structure. Core Logic:** Implements `heapify_up` (for insertion) and `heapify_down` (for extraction) to maintain the Min Heap property. Demonstration:** Includes a `main()` function demonstrating all operations and memory cleanup. #### ⚙️ Supported Operations & Complexity | Operation | Time Complexity | | :--- | :--- | | **Insert** | $O(\log n)$ | | **Extract Min** | $O(\log n)$ | | **Get Min (Peek)** | $O(1)$ | | **Search** | $O(n)$ | | **Display** | $O(n)$ | #### References No specific external references needed. #### Checklist - [x] Added description of change - [x] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [x] Added tests and example, test must pass (Included in the `main` function) - [x] Relevant documentation/comments is changed or added (Added extensive function documentation and header comments) - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) (The title should be `feat(data-structure): Add Min Binary Heap implementation in C`) - [x] Search previous suggestions before making a new one, as yours may be a duplicate. - [x] I acknowledge that all my contributions will be made under the project's license. Notes: Implements the requested Min Binary Heap data structure.
claunia added the pull-request label 2026-01-29 15:29:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#2140