Repository navigation
feat(trees): add SparseTable for O(1) idempotent range queries - #7797
Merged
DenizAltunkapan merged 3 commits intoDec 3, 2026
Merged
Conversation
mayankcodes-dev
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
December 2, 2026 18:04
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7797 +/- ##
============================================
+ Coverage 82.97% 83.00% +0.02%
- Complexity 8676 8692 +16
============================================
Files 848 849 +1
Lines 26502 26548 +46
Branches 5169 5176 +7
============================================
+ Hits 21991 22036 +45
+ Misses 3726 3725 -1
- Partials 785 787 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
DenizAltunkapan
approved these changes
Dec 3, 2026
DenizAltunkapan
left a comment
Member
There was a problem hiding this comment.
@mayankcodes-dev looka good
DenizAltunkapan
enabled auto-merge (squash)
December 3, 2026 21:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7794.
Describe your change:
Adds
SparseTableundercom.thealgorithms.datastructures.treesfor static range queries inO(1)time (afterO(n log n)preprocessing andO(n log n)space) on associative idempotent operations, plusO(log n)queryAssociativefor general associative operations.Usage example:
SparseTableTestcovering exhaustive all-subarray RMQ, randomized RMxQ stress tests, range GCD (with0, negative numbers, andInteger.MIN_VALUE), non-idempotentsum/XOR, defensive array copying, and out-of-bounds / invalid-input validation.javac --release 21 -Xlint:all -Werror, JUnit 5, Checkstyle, andclang-format16.Checklist:
clang-format -i --style=file path/to/your/file.java