[ENHANCEMENT] Add Wavelet Tree Data Structure#7414
[ENHANCEMENT] Add Wavelet Tree Data Structure#7414space0032 wants to merge 4 commits intoTheAlgorithms:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7414 +/- ##
============================================
+ Coverage 79.53% 79.61% +0.07%
- Complexity 7175 7217 +42
============================================
Files 798 799 +1
Lines 23474 23579 +105
Branches 4617 4639 +22
============================================
+ Hits 18670 18772 +102
Misses 4055 4055
- Partials 749 752 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a new WaveletTree data structure under com.thealgorithms.datastructures.trees, providing rank, select, and kthSmallest (quantile) queries over an integer sequence, along with JUnit tests validating core behavior.
Changes:
- Introduces
WaveletTreeimplementation withrank(x, i),select(x, k), andkthSmallest(l, r, k). - Adds JUnit test suite covering typical cases, invalid inputs, empty/singleton arrays, and negative values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/main/java/com/thealgorithms/datastructures/trees/WaveletTree.java |
Adds the Wavelet Tree implementation and query methods. |
src/test/java/com/thealgorithms/datastructures/trees/WaveletTreeTest.java |
Adds JUnit tests for rank/select/kthSmallest, including some edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The merged file is not showing up in the repo |
Description
This Pull Request introduces the Wavelet Tree data structure to the
datastructures/treespackage in the repository. A Wavelet Tree is a highly efficient and versatile data structure used for compressed storage of sequences and answering complex range-based queries inO(log U)time.The main operations implemented are:
rank(x, i): Determines how many times the valuexappears from the beginning of the array up to the indexi.kthSmallest(l, r, k): Finds thek-th smallest element in the subarray[l, r].The functionality is generalized to handle large input arrays with an arbitrary range of values (
minValueandmaxValue).Files Added
WaveletTree.java: Contains the implementation of the Wavelet Tree data structure.WaveletTreeTest.java: Contains JUnit test cases to validate the correctness of the methods and handle edge cases.Complexity