Power Set in Lexicographic order
There is a set contains N no. of unsorted characters. You have to find out the power sets in lexicographic order of a given set of numbers and print them.
Input:
Test case T
//T no. of line with the value of N and corresponding values.
E.g.
2
4
d c b a
2
f u
1<=T<=100
1<=N<=1000
Output:
Print the power subsets of the set in lexicographic order.
Example
T=2
N=4
d c b a
Output:
a
a b
a b c
a b c d
a b d
a c
a c d
a d
b
b c
b c d
b d
c
c d
d
N=2
f u
Output:
f
f u
u
Algorithm:
Here we use the vector STL to store the subsets.
C++ implementation:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer