**DOWNLOAD FREE PDF** **<<CLICK HERE>>**

## 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%%

Your answers are highlighted below.

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?

subset of all sets | |

set of all subsets | |

set of particular subsets | |

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?

2 | |

4 | |

6 | |

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 2

^{n}. Thus, here number of elements will be 2^{3}=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?

2 | |

4 | |

6 | |

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; }

function returns true if N is odd | |

function returns true if N is even | |

function returns true if ith bit of N is set | |

function returns false if ith bit of N is set |

Question 4 Explanation:

As the value of 1 << i is 2

^{i}so the given function checks whether the i^{th}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, b, ab, c, ac, bc, abc, | |

a, b, ab, c, ac, bc, abc | |

, a, b, ab, c, ac, bc, abc, | |

, 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.