Combinatorics (Fall 2010)/Basic enumeration

From TCS Wiki
Revision as of 06:52, 9 July 2010 by imported>WikiSysop (Subsets of fixed size)
Jump to navigation Jump to search

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)