Skip to content

Commit 6bc3baf

Browse files
committed
Renamed directory
1 parent 0ca8417 commit 6bc3baf

File tree

75 files changed

+17
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+17
-2
lines changed

14_bit_manipulation/12_generate_subsets_using_bitmasking.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
#include <cstring>
1515
using namespace std;
1616

17-
17+
// function to extract out character which maps with set-bit of number n
1818
void filterChars(char c[], int n)
1919
{
2020
int idx=0;
21-
2221
while(n)
2322
{
2423
int last_bit = n&1;
@@ -36,6 +35,7 @@ void filterChars(char c[], int n)
3635
void printSubsets(char c[])
3736
{
3837
int len = strlen(c);
38+
// iterating over the list of numbers
3939
for(int i=0; i < (1<<len); i++)
4040
{
4141
filterChars(c, i);
@@ -73,4 +73,19 @@ int main()
7373
ac
7474
bc
7575
abc
76+
77+
78+
Approach:
79+
80+
- Extracting out character which maps with set-bit from number 0 to 7
81+
82+
cba
83+
0 : 000 | " "
84+
1 : 001 | a
85+
2 : 010 | b
86+
3 : 011 | ab
87+
4 : 100 | c
88+
5 : 101 | ac
89+
6 : 110 | bc
90+
7 : 111 | abc
7691
*/

0 commit comments

Comments
 (0)