Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementation to [count number of set bits of a number] (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an integer. More...
#include <cassert>
#include <iostream>
Namespaces | |
namespace | bit_manipulation |
for IO operations | |
namespace | count_of_set_bits |
Functions for the count sets bits implementation. | |
Functions | |
std::uint64_t | bit_manipulation::count_of_set_bits::countSetBits (std ::int64_t n) |
The main function implements set bit count. | |
static void | test () |
int | main () |
Main function. | |
Implementation to [count number of set bits of a number] (https://www.geeksforgeeks.org/count-set-bits-in-an-integer/) in an integer.
We are given an integer number. We need to calculate the number of set bits in it.
A binary number consists of two digits. They are 0 & 1. Digit 1 is known as set bit in computer terms. Worst Case Time Complexity: O(log n) Space complexity: O(1)
std::uint64_t bit_manipulation::count_of_set_bits::countSetBits | ( | std ::int64_t | n | ) |
The main function implements set bit count.
n | is the number whose set bit will be counted |
n
int main | ( | void | ) |
Main function.
|
static |