What Of The Following Code Prints The Power Set Of A Given Set #1182
What of the following code prints the power set of a given set?
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Number Theory - Generating Subsets - Quiz No.1.
What of the following code prints the power set of a given set?
#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; }
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes