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!

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Author has not responded to the comments for over 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant