gs gs122 Number Theory - Generating Subsets - Quiz No.1
gs gs122 Data Communication and Computer Network Quiz
This quiz belongs to book/course code gs gs122 Data Communication and Computer Network of gs organization. We have 268 quizzes available related to the book/course Data Communication and Computer Network. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Number Theory. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
bool check (int N) { if( N & (1 << i) ) return true; else return false; }
#include <stdio.h> #include <math.h> void PowerSet(char *set, int set_size) { unsigned int pow_size = pow(2, set_size); int count, j; for(count = 0; count < pow_size; count++) { for(j = 0; j < set_size; j++) { if(count & (1<<j)) printf("%c", set[j]); } printf(","); } } int main() { char strset[] = {'a','b','c'}; PowerSet(strset, 3); return 0; }
#include <stdio.h> #include <math.h> void PowerSet(char *set, int set_size) { unsigned int pow_size = pow(2, set_size); int count, j; for(count = 0; count < pow_size; count++) { for(j = 0; j < set_size; j++) { if(count & (1<<j)) printf("%c", set[j]); } printf(","); } } int main() { char strset[] = {'a','b','c'}; PowerSet(strset, 3); return 0; }
#include <stdio.h> #include <math.h> void PowerSet(char *set, int set_size) { unsigned int pow_size = pow(2, set_size); int count, j; for(count = 0; count < pow_size; count++) { for(j = 0; j < set_size; j++) { if(count & (1<<j)) printf("%c", set[j]); } printf(","); } } int main() { char strset[] = {'a','b','c'}; PowerSet(strset, 3); return 0; }
#include<iostream> using namespace std; void Set(string str, int index = 0, string curr = "") { int n = str.size(); if (index == n) { cout << curr << endl; return; } Set(str, index , curr + str[index]); Set(str, index + 1, curr); } int main() { string str = "ab"; Set(str); return 0; }
#include<iostream> using namespace std; void Set(string str, int index = 0, string curr = "") { int n = str.size(); if (index == n) { cout << curr << endl; return; } Set(str, index + 1, curr + str[index]); Set(str, index , curr); } int main() { string str = "ab"; Set(str); return 0; }
#include<iostream> using namespace std; void Set(string str, int index = 0, string curr = "") { int n = str.size(); if (index == n) { cout << curr << endl; return; } Set(str, index + 1, curr + str[index]); Set(str, index + 1, curr); } int main() { string str = "ab"; Set(str); return 0; }
#include<iostream> using namespace std; void Set(string str, int index = 0, string curr = "") { int n = str.size(); if (index == n) { cout << curr << endl; return; } Set(str, index , curr+str); Set(str, index + 1, curr); } int main() { string str = "ab"; Set(str); return 0; }
#include <bits/stdc++.h> using namespace std; void Set(string str, int ind = -1, string curr = "") { int n = str.size(); if (ind == n) return; cout << curr << ","; for (int i = ind+ 1; i < n; i++) { curr += str[i]; Set(str, i, curr); curr.erase(curr.size() - 1); } return; } int main() { string str = "abc"; Set(str); return 0; }
#include <bits/stdc++.h> using namespace std; void Set(string str, int ind = -1, string curr = "") { int n = str.size(); if (ind == 0) return; cout << curr << ","; for (int i = ind+ 1; i < n; i++) { curr += str[i]; Set(str, i, curr); curr.erase(curr.size() - 1); } return; } int main() { string str = "abc"; Set(str); return 0; }
#include <bits/stdc++.h> using namespace std; void Set(string str, int ind = -1, string curr = "") { int n = str.size(); if (ind == n) return; cout << curr << ","; for (int i = ind+ 1; i < n; i++) { curr += str[i]; Set(str, i, curr); curr.erase(curr.size() -2); } return; } int main() { string str = "abc"; Set(str); return 0; }
#include <bits/stdc++.h> using namespace std; void Set(string str, int ind = -1, string curr = "") { int n = str.size(); if (ind == n) return; cout << str << ","; for (int i = ind+ 1; i < n; i++) { curr += str[i]; Set(str, i, curr); curr.erase(curr.size() - 1); } return; } int main() { string str = "abc"; Set(str); return 0; }