# Data Structure Questions and Answers-Generating Subsets

## Data Structure Questions and Answers-Generating Subsets

 Question 1
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
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
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
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
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,