Combinatorics (Fall 2010)/Basic enumeration: Difference between revisions

From TCS Wiki
Jump to navigation Jump to search
imported>WikiSysop
Line 50: Line 50:


=== Subsets of fixed size ===
=== Subsets of fixed size ===
We then count the number of subsets of fixed size of a set.
We then count the number of subsets of fixed size of a set. Again, let <math>S=\{x_1,x_2,\ldots,x_n\}</math> be an <math>n</math>-set. We define <math>{S\choose k}</math> to be the set of all <math>k</math>-elements subsets (or '''<math>k</math>-subsets''') of <math>S</math>. Formally, <math>{S\choose k}=\{T\subseteq S\mid |T|=k\}</math>. The set <math>{S\choose k}</math> is sometimes called the '''<math>k</math>-uniform''' of <math>S</math>.
 
We denote that <math>{n\choose k}=\left|{S\choose k}\right|</math>. The notation <math>{n\choose k}</math> is read "<math>n</math> choose <math>k</math>".
 
{{Theorem|Theorem|
:<math>{n\choose k}=\frac{n(n-1)\cdots(n-k+1)}{k(k-1)\cdots 1}=\frac{n!}{k!(n-k)!}</math>.
}}
{{Proof|
The number of '''ordered''' <math>k</math>-subsets of an <math>n</math>-set is <math>n(n-1)\cdots(n-k+1)</math>. Every <math>k</math>-subset has <math>k!=k(k-1)\cdots1</math> ways to order it.
}}
 
;Some notations
* <math>n!=n(n-1)(n-2)\cdots 1</math>, read "<math>n</math> factorial". A convention is that <math>0!=1</math>.
* <math>n(n-1)\cdots(n-k+1)=\frac{n!}{(n-k)!}</math> is usually denoted as <math>(n)_k</math>, read "<math>n</math> lower factorial <math>k</math>".
 
{{Theorem|Proposition|
:<math>{n\choose k}={n\choose n-k}</math>.
}}
{{Proofbox|
'''Proof 1 (numerical proof).'''
:<math>{n\choose k}=\frac{n!}{k!(n-k)!}={n\choose n-k}</math>.
}}
{{Proofbox|
'''Proof 2 (combinatorial proof).'''
:Choosing <math>k</math> elements from an <math>n</math>-set is equivalent to choosing the <math>n-k</math> elements to leave out. Formally, every <math>k</math>-subset <math>T\in{S\choose k}</math> is uniquely specified by its complement <math>S\setminus T\in {S\choose n-k}</math>, and the same holds for <math>(n-k)</math>-subsets, thus we have a bijection between <math>{S\choose k}</math> and <math>{S\choose n-k}</math>.
}}


== Permutations and Partitions ==
== Permutations and Partitions ==

Revision as of 06:52, 9 July 2010

Counting Problems

Functions and Tuples

Sets and Multisets

Subsets

We want to count the number of subsets of a set.

LetS={x1,x2,,xn} be an n-element set, or n-set for short. Let 2S={TTS} denote the set of all subset of S. 2S is called the power set of S.

We give a combinatorial proof that |2S|=2n. We observe that every subset T2S corresponds to a unique bit-vector v{0,1}S, such that each bit vi indicates whether xiS. Formally, define a map ϕ:2S{0,1}n by ϕ(T)=(v1,v2,,vn), where

vi={1if xiT0if xiT.

The map ϕ is a bijection (a 1-1 correspondence). The proof that ϕ is a bijection is left as an exercise.

We know that |{0,1}n|=2n. Why is that? We apply "the rule of product": for any finite sets P and Q, the cardinality of the Cartesian product |P×Q|=|P||Q|. We can write {0,1}n={0,1}×{0,1}n1, thus |{0,1}n|=2|{0,1}n1|, and by induction, |{0,1}n|=2n.

Since there is a bijection between 2S and {0,1}n, it holds that |2S|=|{0,1}n|=2n. Here we use "the rule of bijection": if there exists a bijection between finite sets P and Q, then |P|=|Q|.

There are two elements of this proof:

  • Find a 1-1 correspondence between subsets of an n-set and n-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 U can be represented by an array of |U| bits.
  • The rule of bijection: if there is a 1-1 correspondence between two sets, then their cardinalities are the same.

Many counting problems are solved by establishing a bijection between the set to be counted and some easy-to-count set. This kind of proofs are usually called (non-rigorously) combinatorial proofs.


We give an alternative proof that |2S|=2n. Define the function f(n)=|2Sn|, where Sn={x1,x2,,xn} is an n-set. Our goal is to compute f(n). We prove the following recursion for f(n).

Lemma
f(n)=2f(n1).
Proof.

Fix an element xn, let U be the set of subsets of Sn that contain xn and let V be the set of subsets of Sn that do not contain xn. It is obvious that U and V are disjoint (i.e. UV=) and 2Sn=UV, because any subset of Sn either contains xn or does not contain xn but not both.

We apply "the rule of sum": for any disjoint finite sets P and Q, the cardinality of the union |PQ|=|P|+|Q|.

Therefore,

f(n)=|UV|=|U|+|V|.

The next observation is that |U|=|V|=f(n1), because V is exactly the 2Sn1, and U is the set resulting from add xn to every member of 2Sn1. Therefore,

f(n)=|U|+|V|=f(n1)+f(n1)=2f(n1).

The elementary case f(0)=1, because has only one subset . Solving the recursion, we have that |2S|=f(n)=2n.

Subsets of fixed size

We then count the number of subsets of fixed size of a set. Again, let S={x1,x2,,xn} be an n-set. We define (Sk) to be the set of all k-elements subsets (or k-subsets) of S. Formally, (Sk)={TS|T|=k}. The set (Sk) is sometimes called the k-uniform of S.

We denote that (nk)=|(Sk)|. The notation (nk) is read "n choose k".

Theorem
(nk)=n(n1)(nk+1)k(k1)1=n!k!(nk)!.
Proof.

The number of ordered k-subsets of an n-set is n(n1)(nk+1). Every k-subset has k!=k(k1)1 ways to order it.

Some notations
  • n!=n(n1)(n2)1, read "n factorial". A convention is that 0!=1.
  • n(n1)(nk+1)=n!(nk)! is usually denoted as (n)k, read "n lower factorial k".
Proposition
(nk)=(nnk).

Proof 1 (numerical proof).

(nk)=n!k!(nk)!=(nnk).

Proof 2 (combinatorial proof).

Choosing k elements from an n-set is equivalent to choosing the nk elements to leave out. Formally, every k-subset T(Sk) is uniquely specified by its complement ST(Snk), and the same holds for (nk)-subsets, thus we have a bijection between (Sk) and (Snk).

Permutations and Partitions

The twelvfold way

f:NM

Elements of N Elements of M Any f Injective (1-1) f Surjective (on-to) f
distinguishable distinguishable mn (m)n m!S(n,m)
indistinguishable distinguishable ((mn)) (mn) ((mnm))
distinguishable indistinguishable k=1mS(n,k) {1if nm0if n>m S(n,m)
indistinguishable indistinguishable k=1mpk(n) {1if nm0if n>m pm(n)