Add Reverse Bits algorithm to Bit Manipulation module#963
Add Reverse Bits algorithm to Bit Manipulation module#963siriak merged 1 commit intoTheAlgorithms:masterfrom
Conversation
|
@siriak, This is ready to be merged. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #963 +/- ##
==========================================
+ Coverage 95.57% 95.58% +0.01%
==========================================
Files 337 338 +1
Lines 22015 22052 +37
==========================================
+ Hits 21040 21078 +38
+ Misses 975 974 -1 ☔ 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 bit reversal algorithm to the bit manipulation module, implementing a function that reverses the bits of a 32-bit unsigned integer using bitwise operations. The implementation follows the repository's documentation standards with comprehensive module-level and function-level documentation.
- Adds
reverse_bitsfunction with O(1) time and space complexity - Includes comprehensive test coverage for edge cases and typical inputs
- Properly integrates the new module into the existing codebase structure
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/bit_manipulation/reverse_bits.rs | New implementation of bit reversal algorithm with documentation and tests |
| src/bit_manipulation/mod.rs | Module declaration and public export of reverse_bits function |
| DIRECTORY.md | Added reverse_bits entry to documentation index (plus formatting improvements to other entries) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Adds a function to reverse the bits of a 32-bit unsigned integer.
Changes
reverse_bits.rstosrc/bit_manipulation/src/bit_manipulation/mod.rsto include the new moduleAlgorithm
The function iterates through all 32 bits, shifting the result left and extracting each bit from the input using bitwise AND, then OR-ing it into the result.
Time Complexity: O(1) - Always processes exactly 32 bits
Space Complexity: O(1) - Uses constant extra space
Testing
All tests pass: