I have a set with $N$ members $\{1,2, \dots, N\}$. I would like to know number of set partitions in which each subset is either of size $1$ or $2$, i.e., cardinality of each subset in the partition is maximum $2$. For example with $N=3$, we have the set partitions of maximum size $2$ are $\{1,2,3\}, \{(1,2),3)\}, \{1,(2,3)\}, \{(1,3),2\}$. However I am not interested in $\{(1,2,3)\}$ since it is of length $3$. Kindly tell me number of such set partitions for a set with $N$ members.
-
I would go about it as follows. First, assume that $N$ is an even number, i.e $N = 2m$ for some $m \in \mathbb N$. Then think about the number of set partitions in which there are exactly $k$ pairs (and the rest singletons) for $0 \leq k \leq m$. – H1ghfiv3 Feb 16 '16 at 11:16
-
1This is OEIS sequence A000085. Here is a table of values. There is a recurrence $A_n=A_{n-1}+(n-1)A_{n-2}$. The exponential generating function is $\exp(x+\frac12x^2)$. – bof Feb 16 '16 at 11:19
3 Answers
This is equal to the number of involutions in the symmetric group $S_n$ (permutations whose square is the identity), via the correspondence that associates to such an involution its set of orbits. The exponential generating function for these numbers $f_n$ is $$ \sum_{n\in\Bbb N}f_n\frac{X^n}{n!}=\exp\left(X+\frac{X^2}2\right) $$ where one may interpret the term $X$ in the argument of $\exp$ as the fact that fixed points are allowed, and the term $\frac{X^2}2$ as the fact that $2$-cycles are allowed. This number is also the number of standard Young tableaux of size$~n$. (This is actually one of the first exercises in Stanley's Enumerative Combinatorics book, IIRC.)
- 115,048
-
Thank you so much for the help. I have one more query. With N members .. if I have a problem to search all such possible set partition to find the best (according to some weight assigned to each set partition).. what can I comment on the problem...I mean, time complexity and class of this problem (P, NP). – – Sabyasachi G Feb 18 '16 at 20:10
This is OEIS sequence A000085. Here is a table of values. There is a recurrence $p_n=p_{n-1}+(n-1)p_{n-2}$. The exponential generating function is $\exp(x+\frac12x^2)$.
This sequence has come up before, here and here and here and here and here.
More generally, given sets $A\subseteq\{0,1,2,3,\dots\}$ and $B\subseteq\{1,2,3,\dots\},$ if $p_n$ counts the partitions of $\{1,2,\dots,n\}$ subject to the conditions that the number of cells belongs to $A$ and the size of each cell belongs to $B$, then the exponential generating function is $$\sum_{n=0}^\infty\frac{p_nx^n}{n!}=e_A(e_B(x))$$ where $$e_S(x)=\sum_{n\in S}\frac{x^n}{n!}.$$
-
Thank you so much for the help. I have one more query. With N members .. if I have a problem to search all such possible set partition to find the best (according to some weight assigned to each set partition).. what can I comment on the problem...I mean, time complexity and class of this problem (P, NP). – – Sabyasachi G Feb 18 '16 at 20:09
-
Explanation of recurrence relation mentioned by @bof.
Denote the number of these partitions by $p_{N}$.
Then $p_{0}=p_{1}=1$. For $n\geq2$ we have the relation:
$$p_{n}=\left(n-1\right)p_{n-2}+p_{n-1}$$
There are $p_{n-1}$ partitions such that $\{1\}$ is one of its elements.
They are induced by the sortlike partitions of $\{2,\dots,n\}$.
For $k=2,\dots,n$ there are $p_{n-2}$ partitions such that $\{1,k\}$ is one of its elements.
They are induced by the sortlike partitions of $\{2,\dots,k-1,k+1,\dots n\}$.
- 151,093
-
Thank you so much for the help. I have one more query. With N members .. if I have a problem to search all such possible set partition to find the best (according to some weight assigned to each set partition).. what can I comment on the problem...I mean, time complexity and class of this problem (P, NP). – Sabyasachi G Feb 18 '16 at 20:08
-
1If you know noting particular about the definition of you weight function, then you would have to actually traverse all these partitions to find the minimum. That has pretty bad complexity (from the recurrence relation, clearly worse than exponential in $n$). If you know more about your weight function (for instance if it is defined as the sum of some coefficient associated to individual pairs and singletons in the partition), then you man be able to find a much better algorithm. Without algorithm, no complexity can be stated. – Marc van Leeuwen Feb 19 '16 at 05:29
-
Thank you for your reply. I am able to solve the problem in polynomial time using graph theoretic matching algorithm since I can assign weight to each 1 member or 2 member subsets. However, in my research work, I like to comment about the exhaustive search problem. Certainly the exhaustive search problem is not polynomial time. Should I mention that the exhaustive search is exponential time complexity? – Sabyasachi G Feb 19 '16 at 09:27
-
Sorry, but my knowledge about algorithms and the time they consume is poor/absent. So I cannot give you a good advice on this. – drhab Feb 19 '16 at 13:05