Skip to content

[FEATURE REQUEST] Adding the Lowest Set Bit Implementation #5566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prayas7102 opened this issue Oct 4, 2024 · 4 comments
Closed

[FEATURE REQUEST] Adding the Lowest Set Bit Implementation #5566

prayas7102 opened this issue Oct 4, 2024 · 4 comments

Comments

@prayas7102
Copy link
Contributor

prayas7102 commented Oct 4, 2024

What would you like to Propose?

Overview
The goal of this proposal is to implement a LowestSetBit class that provides efficient methods for manipulating and analyzing the lowest set bit in a given integer. This class will be useful for various applications in competitive programming, algorithm design, and software development where bit manipulation is required.

Objectives
Isolation of the Lowest Set Bit: Create a method to isolate the lowest set bit of a number using bitwise operations.
Providing Information: Return the number after clearing lowest set bit.

Key Features
Efficiency: The operations will be performed using bitwise manipulation, ensuring O(1) time complexity for each operation.
Edge Case Handling: The class will handle edge cases such as zero and negative numbers appropriately.
User-Friendly API: Provide simple methods with clear documentation for ease of use.

This method will return a number after clearing the lowest set bit.

Issue details

Implementation Details

isolateLowestSetBit(int n): This method will return the value of the lowest set bit in the integer n.
Implementation: return n & -n; (using two's complement to isolate the lowest set bit).

Testing
To ensure the functionality and reliability of the LowestSetBit class, a comprehensive test suite will be created. The tests will cover:

  • Regular positive integers.
  • Edge cases like zero and one.
  • Powers of two.
  • Numbers with all bits set.
  • Negative integers.

Additional Information

Required PR for this issue #5567

@AnamuddinAhmad
Copy link

I want to work for this problem/Issue please assing me for this work.

@ishanki19-pixel
Copy link

I have made a PR for the above issue: #5574
Please review it!
If you feel it worthy then please label it as hacktoberfest accepted

Thank you

@Nandinig24
Copy link

Please assign the task to me as a hacktoberfest contributor

@siriak
Copy link
Member

siriak commented Oct 7, 2024

Done in #5567

@siriak siriak closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants