Repository navigation
Add Fenwick tree implementation and tests - #7637
Merged
Merged
Conversation
Rohan45create
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
October 6, 2026 13:36
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7637 +/- ##
============================================
+ Coverage 81.95% 82.01% +0.06%
- Complexity 8273 8282 +9
============================================
Files 840 840
Lines 25865 25872 +7
Branches 5052 5053 +1
============================================
+ Hits 21197 21219 +22
+ Misses 3881 3865 -16
- Partials 787 788 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alxkm
requested changes
Oct 6, 2026
alxkm
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix - the infinite loop on update is a real bug and the tests are solid. Two small things before merge: rename the test file to FenwickTreeTest.java (it currently doesn't match the class name), and add some documentation link mentioned in the checklist.
alxkm
approved these changes
Oct 6, 2026
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.
Add FenwickTree tests, bounds checks and Javadoc
update(-1, x)made the index 0, soi & -istayed 0 and the loop never ended.updateandquerynow validate the index and throwIndexOutOfBoundsExceptionoutside[0, n). Before this, out-of-range behavior was inconsistent:update(i >= n)was silently ignored,query(-1)returned 0, and other bad indices threwArrayIndexOutOfBoundsException.IllegalArgumentExceptionfor a negative size.final, Javadoc was added (with a Wikipedia link), and the misleadingquerycomment was corrected (it returns the sum over[0, i]).FenwickTreeTest: fresh tree, single element, prefix sums, repeated updates, negative values, non-power-of-two size, zero size, invalid arguments, and a randomized comparison against naive prefix sums.clang-format -i --style=file path/to/your/file.java