Skip to content

Add Heap data structure implementation with tests#34

Merged
kassane merged 4 commits intoTheAlgorithms:mainfrom
Gabenoob:heap
Feb 6, 2026
Merged

Add Heap data structure implementation with tests#34
kassane merged 4 commits intoTheAlgorithms:mainfrom
Gabenoob:heap

Conversation

@Gabenoob
Copy link
Contributor

@Gabenoob Gabenoob commented Feb 6, 2026

This pull request introduces a new, generic heap data structure implementation and integrates it into the build and test system. The main changes are the addition of a reusable Heap type, updates to the build scripts to support building and testing the heap, and documentation updates to reflect the new file.

Data Structures:

  • Added a generic Heap implementation in dataStructures/heap.zig, supporting both min-heaps and max-heaps via a comparator function, with insert, extract, peek, and size operations. Includes comprehensive tests for both heap types.

Build System:

  • Updated build.zig to support building and running tests for the new heap data structure with the "ds/heap" operation.
  • Updated runall.zig to include the heap data structure in the suite of tests run by default.

Documentation:

  • Added heap.zig to the list of data structure files in CONTRIBUTING.md.

Copilot AI review requested due to automatic review settings February 6, 2026 08:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a generic heap data structure implementation to support both min-heaps and max-heaps. The implementation uses an ArrayList-backed binary heap with standard heap operations and integrates with the existing build and test infrastructure.

Changes:

  • Added a new generic Heap type in dataStructures/heap.zig with insert, extract, peek, and size operations
  • Updated build.zig to add build configuration for the heap data structure
  • Updated runall.zig to include heap tests in the default test suite
  • Updated CONTRIBUTING.md documentation to list the new heap.zig file

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
dataStructures/heap.zig New generic heap implementation with min/max heap support via comparator functions, including siftUp/siftDown operations and comprehensive tests
build.zig Added build configuration for "ds/heap" operation
runall.zig Added heap to the default test suite
CONTRIBUTING.md Updated file listing to include heap.zig in alphabetical order

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kassane kassane merged commit 2091a82 into TheAlgorithms:main Feb 6, 2026
5 checks passed
@Gabenoob Gabenoob deleted the heap branch February 9, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants