Skip to content
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

feat: Modified count_set_bits.cpp #1634

Merged
merged 10 commits into from
Oct 17, 2021

Conversation

prashant-th18
Copy link
Contributor

@prashant-th18 prashant-th18 commented Oct 1, 2021

Changed the algorithm of Finding set-bits of a number which is much faster than previous one.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix clang-tidy warnings.

@Panquesito7 Panquesito7 added automated tests are failing Do not merge until tests pass awaiting modification Do not merge until modifications are made enhancement New feature or request Proper Documentation Required requested to write the documentation properly requested changes changes have been requested Improvement improvement in previously written codes and removed enhancement New feature or request labels Oct 5, 2021
@Panquesito7 Panquesito7 removed the automated tests are failing Do not merge until tests pass label Oct 5, 2021
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! 😄

Comment on lines 17 to 18
#include <cassert> // for assert
#include <iostream> // for I/O operations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <cassert> // for assert
#include <iostream> // for I/O operations
#include <cassert> /// for assert
#include <iostream> /// for IO operations

Comment on lines 25 to 29
* @namespace count_of_set_bits
* @brief Functions for the [count sets
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/)
* implementation
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @namespace count_of_set_bits
* @brief Functions for the [count sets
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/)
* implementation
*/
* @namespace count_of_set_bits
* @brief Functions for the [count sets
* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/)
* implementation
*/

Comment on lines 78 to 82
int main()
{
test(); // run self-test implementations
return 0;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the indentation in this part of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. :)

@Panquesito7 Panquesito7 changed the title Modified count_set_bits.cpp feat: Modified count_set_bits.cpp Oct 6, 2021
bit_manipulation/count_of_set_bits.cpp Show resolved Hide resolved
* We are given an integer number. Let’s say, number. The task is to first
* calculate the binary digit of a number and then calculate the total set bits
* of a number.
* We are given a integer number. We need to calculate number of set bits in it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* We are given a integer number. We need to calculate number of set bits in it.
* We are given an integer number. We need to calculate the number of set bits in it.

* bits](https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an
* integer.
* @brief Implementation to [count number of set bits of a number]
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/)
* (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an
* integer.

Co-authored-by: David Leal <halfpacho@gmail.com>
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there! 😄

bit_manipulation/count_of_set_bits.cpp Outdated Show resolved Hide resolved
bit_manipulation/count_of_set_bits.cpp Outdated Show resolved Hide resolved
Co-authored-by: David Leal <halfpacho@gmail.com>
@Panquesito7 Panquesito7 removed the Proper Documentation Required requested to write the documentation properly label Oct 8, 2021
Co-authored-by: David Leal <halfpacho@gmail.com>
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Thank you for your contribution! 😄👍🎉
You can join our Discord server and get the contributor role! 🚀

@Panquesito7 Panquesito7 added approved Approved; waiting for merge and removed awaiting modification Do not merge until modifications are made requested changes changes have been requested labels Oct 10, 2021
Copy link
Member

@aminoxix aminoxix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prashant-th18: LGTM! 🥳

@Panquesito7 Panquesito7 merged commit 6272b2a into TheAlgorithms:master Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved; waiting for merge Improvement improvement in previously written codes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants