[Math] How many ways to partition $n$ elements into two nonempty subsets

combinatoricsdiscrete mathematicsgroup-theory

How can we find the total number of ways in which we can divide $n$ elements into two subsets such that none of them are empty and the union of both sets should be equal to the whole set?

Eg. If $S=\{1,2,3\}$, the answer can be $A=\{1,2\}$, $B=\{3\}$ or $A = \{1,3\}$ and $B=\{2\}$ or $A=\{2,3\}$ and $B=\{1\}$.

Best Answer

Use the power set of $S$. For example when $S=\{1,2,3\}$ the power set is

$$ \mathcal P(S) = \Big\{ \emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\} \Big\}$$

Choosing a pair $(A,B)$ of subsets such that $A\cup B=S$ and $A$ and $B$ are nonempty is equivalent to choosing any subset $A$ (besides the empty set and $S$), then let $B$ be the complement of $A$:

$$B = \{ x\in S : x\notin A \} $$

Since the power set has $2^n$ elements, there are $2^n - 2$ ways to choose the set $A$ (we excluded sets $\emptyset$ and $S$). However, we have double-counted, since for example we counted both $A=\{1,2\}$, $B=\{3\}$ and $A=\{3\}$, $B=\{1,2\}$ separately, when really they are the same. Thus we divide by $2$, so the answer is

$$ \frac{2^n - 2}{2} = 2^{n-1} - 1 $$