# Backtracking to find all subsets

There is a set contains **N** number of elements. You have to find out all the possible subsets of the given set and print them.

Input:
Test case T
//T no. of lines with the value of N and corresponding values.
E.g.
2
4
1 2 3 4
2
7 8
1<=T<=100
1<=N<=1000
Output:
Print the subsets of the set.

**Example**

T=2
Input:
N=4
1 2 3 4
Output:
1 2
1 2 3
1 2 3 4
1 2 4
1 3
1 3 4
1 4
2
2 3
2 3 4
2 4
3
3 4
4
Input:
N=2
7 8
Output:
7
7 8
8

Let, there is a Set S having N number of elements,

The process to print the subsets of the set is a problem of combination and permutation. To get the result we use the backtracking process.

Here, we take a subset of that set in our consideration and consider two things,

f(i)).not f(i)).Algorithm:Here we use the vector STL to store the subsets.

C++ implementation:

need an explanation for this answer? contact us directly to get an explanation for this answerOutput