Combinatorics (Fall 2010)/Basic enumeration: Difference between revisions
Line 4: | Line 4: | ||
== Sets and Multisets == | == Sets and Multisets == | ||
Let<math>S=\{x_1,x_2,\ldots,x_n\}</math> be an <math>n</math>-element set, or '''<math>n</math>-set''' for short. Let <math>2^S=\{T\mid T\subset S\}</math> denote the set of all subset of <math>S</math>. <math>2^S</math> is called the '''power set''' of <math>S</math>. | === Subsets === | ||
We want to count the number of subsets of a set. | |||
Let<math>S=\{x_1,x_2,\ldots,x_n\}</math> be an <math>n</math>-element set, or '''<math>n</math>-set''' for short. | |||
Let <math>2^S=\{T\mid T\subset S\}</math> denote the set of all subset of <math>S</math>. <math>2^S</math> is called the '''power set''' of <math>S</math>. | |||
We give a combinatorial proof that <math>|2^S|=2^n</math>. We observe that every subset <math>T\in 2^S</math> corresponds to a unique bit-vector <math>v\in\{0,1\}^S</math>, such that each bit <math>v_i</math> indicates whether <math>x_i\in S</math>. Formally, define a map <math>\phi:2^S\rightarrow\{0,1\}^n</math> by <math>\phi(T)=(v_1,v_2,\ldots,v_n)</math>, where | |||
:<math> | |||
v_i=\begin{cases} | |||
1 & \mbox{if }x_i\in T\\ | |||
0 & \mbox{if }x_i\not\in T. | |||
\end{cases} | |||
</math> | |||
The map <math>\phi</math> is a '''bijection''' (a 1-1 correspondence). The proof that <math>\phi</math> is a bijection is left as an exercise. | |||
We know that <math>|\{0,1\}^n|=2^n\,</math>. Since there is a bijection from <math>2^S</math> to <math>\{0,1\}^n</math>, it holds that <math>|2^S|=|\{0,1\}^n|=2^n\,</math>. Here we use '''the rule of bijection''': if there exists a bijection from <math>\mathcal{S}</math> to <math>\mathcal{T}</math>, then <math>|\mathcal{S}|=|\mathcal{T}|</math>. | |||
There are two elements of this proof: | |||
* Find a 1-1 correspondence between subsets of an <math>n</math>-set and <math>n</math>-bit vectors. | |||
: An application of this in Computer Science is that we can use bit-array as a data structure for sets: any set defined over a '''universe''' <math>U</math> can be represented by an array of <math>|U|</math> bits. | |||
* The rule of bijection: if there is a 1-1 correspondence between two sets, then their cardinalities are the same. | |||
=== Subsets of fixed size === | |||
We then count the number of subsets of fixed size of a set. | |||
== Permutations and Partitions == | == Permutations and Partitions == |
Revision as of 03:07, 9 July 2010
Counting Problems
Functions and Tuples
Sets and Multisets
Subsets
We want to count the number of subsets of a set.
Let[math]\displaystyle{ S=\{x_1,x_2,\ldots,x_n\} }[/math] be an [math]\displaystyle{ n }[/math]-element set, or [math]\displaystyle{ n }[/math]-set for short. Let [math]\displaystyle{ 2^S=\{T\mid T\subset S\} }[/math] denote the set of all subset of [math]\displaystyle{ S }[/math]. [math]\displaystyle{ 2^S }[/math] is called the power set of [math]\displaystyle{ S }[/math].
We give a combinatorial proof that [math]\displaystyle{ |2^S|=2^n }[/math]. We observe that every subset [math]\displaystyle{ T\in 2^S }[/math] corresponds to a unique bit-vector [math]\displaystyle{ v\in\{0,1\}^S }[/math], such that each bit [math]\displaystyle{ v_i }[/math] indicates whether [math]\displaystyle{ x_i\in S }[/math]. Formally, define a map [math]\displaystyle{ \phi:2^S\rightarrow\{0,1\}^n }[/math] by [math]\displaystyle{ \phi(T)=(v_1,v_2,\ldots,v_n) }[/math], where
- [math]\displaystyle{ v_i=\begin{cases} 1 & \mbox{if }x_i\in T\\ 0 & \mbox{if }x_i\not\in T. \end{cases} }[/math]
The map [math]\displaystyle{ \phi }[/math] is a bijection (a 1-1 correspondence). The proof that [math]\displaystyle{ \phi }[/math] is a bijection is left as an exercise.
We know that [math]\displaystyle{ |\{0,1\}^n|=2^n\, }[/math]. Since there is a bijection from [math]\displaystyle{ 2^S }[/math] to [math]\displaystyle{ \{0,1\}^n }[/math], it holds that [math]\displaystyle{ |2^S|=|\{0,1\}^n|=2^n\, }[/math]. Here we use the rule of bijection: if there exists a bijection from [math]\displaystyle{ \mathcal{S} }[/math] to [math]\displaystyle{ \mathcal{T} }[/math], then [math]\displaystyle{ |\mathcal{S}|=|\mathcal{T}| }[/math].
There are two elements of this proof:
- Find a 1-1 correspondence between subsets of an [math]\displaystyle{ n }[/math]-set and [math]\displaystyle{ n }[/math]-bit vectors.
- An application of this in Computer Science is that we can use bit-array as a data structure for sets: any set defined over a universe [math]\displaystyle{ U }[/math] can be represented by an array of [math]\displaystyle{ |U| }[/math] bits.
- The rule of bijection: if there is a 1-1 correspondence between two sets, then their cardinalities are the same.
Subsets of fixed size
We then count the number of subsets of fixed size of a set.
Permutations and Partitions
The twelvfold way
[math]\displaystyle{ f:N\rightarrow M }[/math]
Elements of [math]\displaystyle{ N }[/math] | Elements of [math]\displaystyle{ M }[/math] | Any [math]\displaystyle{ f }[/math] | Injective (1-1) [math]\displaystyle{ f }[/math] | Surjective (on-to) [math]\displaystyle{ f }[/math] |
---|---|---|---|---|
distinguishable | distinguishable | [math]\displaystyle{ m^n\, }[/math] | [math]\displaystyle{ \left(m\right)_n }[/math] | [math]\displaystyle{ m!S(n, m)\, }[/math] |
indistinguishable | distinguishable | [math]\displaystyle{ \left({m\choose n}\right) }[/math] | [math]\displaystyle{ {m\choose n} }[/math] | [math]\displaystyle{ \left({m\choose n-m}\right) }[/math] |
distinguishable | indistinguishable | [math]\displaystyle{ \sum_{k=1}^m S(n,k) }[/math] | [math]\displaystyle{ \begin{cases}1 & \mbox{if }n\le m\\ 0& \mbox{if }n\gt m\end{cases} }[/math] | [math]\displaystyle{ S(n,m)\, }[/math] |
indistinguishable | indistinguishable | [math]\displaystyle{ \sum_{k=1}^m p_k(n) }[/math] | [math]\displaystyle{ \begin{cases}1 & \mbox{if }n\le m\\ 0& \mbox{if }n\gt m\end{cases} }[/math] | [math]\displaystyle{ p_m(n)\, }[/math] |