{c,d,e,f}의 모든 부분집합에 {a,b}를 추가한 집합들을 나열한다.{d,e,f}의 모든 부분집합에{a,c}를 추가한 집합들을 나열한다.if S is an empty set // Base case
print nothing;
else
let t be ther first element of S;
find all subsets of S-{t} by calling powerSet(S-{t});
print the subset;
print the subsets with adding t;
여러 개의 집합들을 return해야 한다. 어떻게?if S is an empty set
print P;
else
let t be ther first element of S;
powerSet(P, S-{t}); // t 포함 X
powerSet(PU{t}, S-{t}); // t 포함**

private static char data[] = {'a','b','c','d','e','f'};
private static int n=data.length;
private static boolean [] include = new boolean [n\;
public static void powerSEt(int k) {
if (k==n) {
for (int i = 0; i < n; i++)
if (include[i]) System.out.print(data[i] + " ");
System.out.printaln();
return;
}
include[k] = false;
powerSet(k+1);
include[k] = true;
powerSet(k+1);
}
powerSet(0)로 호출한다. 즉 P는 공집합이고 S는 전체집합이다.Reference