+ 1

What is the best algorithm for getting all subsets of a given set of elements ?

S = {1,2,4,6} ans: {} {1,4} {2,4,6} etc…

4th Nov 2016, 8:06 PM
Aneeshan
Aneeshan - avatar
1 Resposta
+ 1
Heap's or Steinhaus–Johnson–Trotter are the normal ones. Heap's has the most examples floating around. Memoizing will allow speedup. if you can do it in parallel as well (likely in combination with some in-memory storage table) that'll speed it up again. Note the very nature of the problem means the size extrapolates, it gets huge very quickly with longer starting lists.
5th Nov 2016, 12:31 PM
Daniel Couper
Daniel Couper - avatar