I will not write it in Java for you, but here is the pseudo code to give you an idea of how to solve the problem recursively:
l = ['a','b','c'] def f(l, result): if len(l) == 0: print result return first = l[0] rest = l[1:] f(rest, result + [(first,0)]) f(rest, result + [(first,1)]) f (l, [])
This should print something like:
[('a', 0), ('b', 0), ('c', 0)] [('a', 0), ('b', 0), ('c', 1)] [('a', 0), ('b', 1), ('c', 0)] [('a', 0), ('b', 1), ('c', 1)] [('a', 1), ('b', 0), ('c', 0)] [('a', 1), ('b', 0), ('c', 1)] [('a', 1), ('b', 1), ('c', 0)] [('a', 1), ('b', 1), ('c', 1)]