Which Of The Following Code Prints The Power Set Of A Given Set #1180
Which 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.
Which of the following code prints the power set of a given set?
#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; }
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