# Data Structure Questions and Answers-Generating Subsets

## Data Structure Questions and Answers-Generating Subsets

Congratulations - you have completed Data Structure Questions and Answers-Generating Subsets.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%

 Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What is meant by the power set of a set?
 A subset of all sets B set of all subsets C set of particular subsets D empty set
Question 1 Explanation:
Power set of a set is defined as the set of all subsets. Ex- S={1, 2} then P={{}, {1}, {2}{1, 2}}.

 Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Number of elements in the power set of set S={1, 2, 3} will be?
 A 2 B 4 C 6 D 8
Question 2 Explanation:
Power set of a set is defined as the set of all subsets. Number of elements in the power set of a set having n elements is given as 2n. Thus, here number of elements will be 23=8.

 Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Number of elements in the power set of set S={1, 2, 2} will be?
 A 2 B 4 C 6 D 8
Question 3 Explanation:
For finding the number of elements in the power set of the given set we need to remove duplicates. So we will be left with 6 unique elements which will be P={{}, {1}, {2}, {1, 2}, {2, 2}, {1, 2, 2}}.

 Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
Choose the correct statement for the following code segment?

bool check (int N) { if( N & (1 << i) ) return true; else return false; }
 A function returns true if N is odd B function returns true if N is even C function returns true if ith bit of N is set D function returns false if ith bit of N is set
Question 4 Explanation:
As the value of 1 << i is 2i so the given function checks whether the ith bit of N is set or not. If it is set then the function returns true.

 Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER]
What will be the output for the following code?

#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; }
 A a, b, ab, c, ac, bc, abc, B a, b, ab, c, ac, bc, abc C , a, b, ab, c, ac, bc, abc, D , abc, bc, ac, c, ab, b, a,
Question 5 Explanation:
The given code prints the elements of power set of the given set strset[]. It uses binary counter of appropriate length in order to print corresponding subsets of the given set.

Once you are finished, click the button below. Any items you have not completed will be marked incorrect.
There are 5 questions to complete.