Skip to content

Conversation

@abhijeetkundu8
Copy link

Description

This PR adds a C++ implementation of Brian Kernighan’s Algorithm for counting the number of set bits (1s) in the binary representation of a given integer.

Folder & File Path

bit_manipulation/count_set_bits.cpp

Key Details

  • Efficient bit manipulation technique.
  • Time Complexity: O(k), where k = number of set bits.
  • Includes assertions and user input for verification.
  • Author: Abhijeet Kundu

Sample Output

Enter a number: 15
Number of set bits: 4

Checklist

  • Code compiles without errors
  • Proper folder and file naming convention followed
  • Added meaningful comments and assertions
  • No duplicate implementation found in the repo
  • Verified against sample test cases

Screenshots (if applicable)

N/A

Additional Notes

This is my first open-source contribution to TheAlgorithms/C-Plus-Plus repository. Thank you for maintaining such an excellent project for learners and contributors!

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.

1 participant