BacktrackingBit ManipulationRecursion
Given a list of distinct integers, print every possible subset (the power set), including the empty subset. Sort the numbers first. Print each subset on its own line with its numbers in ascending order, and list the subsets in lexicographic order. Print the empty subset as empty.
Input
Line 1: n. Line 2: n distinct integers.
Output
2^n lines, one subset per line, in lexicographic order (empty first).
Constraints
1 <= n <= 10 -10 <= each value <= 10
Example 1
Input
3 1 2 3
Output
empty 1 1 2 1 2 3 1 3 2 2 3 3
The eight subsets of {1, 2, 3}, listed from empty up.