Skip to content

feat(data-structures): add Fenwick tree#44

Merged
0xDevNinja merged 1 commit into
mainfrom
feat/fenwick-tree
Apr 26, 2026
Merged

feat(data-structures): add Fenwick tree#44
0xDevNinja merged 1 commit into
mainfrom
feat/fenwick-tree

Conversation

@0xDevNinja

Copy link
Copy Markdown
Owner

Summary

Adds a Fenwick (binary-indexed) tree over i64 with point update, prefix sum, and inclusive range sum.

Closes #13.

Implementation notes

  • Internally 1-indexed using i & -i trick for parent traversal (wrapping_neg to satisfy clippy on usize).
  • O(log n) per operation, O(n) space.

Test plan

  • Empty
  • Single element with multiple updates
  • 8-element prefix sum after sequential updates
  • range_sum with [lo, hi] inclusive bounds
  • Negative deltas (subtraction support)
  • fmt / clippy / cargo test green

@0xDevNinja

Copy link
Copy Markdown
Owner Author

Reviewed

  • Implementation: i64 Fenwick tree with point update + prefix sum + range sum
  • Tests: 5 cases including negative deltas
  • Complexity: O(log n) per op, O(n) space
  • fmt / clippy / cargo test: green

Merging via rebase.

@0xDevNinja 0xDevNinja merged commit 46eee7b into main Apr 26, 2026
@0xDevNinja 0xDevNinja deleted the feat/fenwick-tree branch April 26, 2026 19:41
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.

Add Fenwick tree (binary indexed tree)

1 participant