Divide a set by other set in all possible variations

159 Views Asked by At

Imagine we have a set S = [a,b,c,d,e,f]. And we have a set N = [1,2,3].

How can we assign elements of S to elements of N in all possible combinations?

The desired result will hold something like this:

  1. [1,[a]], [2,[b,c]], [3,[d,e,f]].
  2. [1,[a]], [2,[b,c,d]],[3,[e,f]].
  3. etc.

Is it a powerset generation problem or anything else? How can I find its complexity and space complexity?

How can I generate those subsets?

1

There are 1 best solutions below

0
On

This problem is related to the powerset generation. You will get |N|^|S| possible mappings.