Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
Jong C. Park
Computer Science Division, KAIST
Discrete Mathematics, 2008 Computer Science Division, KAIST2
Today’s TopicsBasic Principles
Permutations and Combinations
Algorithms for Generating Permutations
Generalized Permutations and Combinations
Binomial Coefficients and Combinatorial Identities
The Pigeonhole Principle
3
• Definition
– Given a set X = {x1, ..., xn} containing n
(distinct) elements,
(a) An r-combination of X is an unordered selection
of r-elements of X (i.e., an r-element subset of X).
(b) The number of r-combinations of a set of n
distinct elements is denoted C(n,r) or (n r).
4
• Theorem– The number of r-combinations of a set of n
distinct objects is C(n,r) = P(n,r)/r! = n(n – 1)···(n– r + 1)/r! = n!/((n - r)!·r!), r n.
• Examples– In how many ways can we select a committee of
three from a group of 10 distinct persons?• C(10,3)
– In how many ways can we select a committee of two women and three men from a group of five distinct women and six distinct men?
• C(5,2)·C(6,3) = 10·20 = 200
5
• Examples
– How many eight-bit strings contain exactly four 1’s?• C(8,4) = 70
– An ordinary deck of 52 cards consists of four suits (clubs, diamonds, hearts, spades) of 13 denominations each (ace, 2-10, jack, queen, king).
(a) How many (unordered) five-card poker hands, selected from an ordinary 52-card deck, are there?
C(52,5) = 2,598,960
(b) How many poker hands contain cards all of the same suit?
4·C(13,5) = 5148
(c) How many poker hands contain three cards of one denomination and two cards of a second denomination?
13·C(4,3)·12·C(4,2) = 3744
6
• Examples– How many routes are there from the lower-left
corner of an n n square grid to the upper-right corner if we are restricted to traveling only to the right or upward?
• C(2n,n)
– How many routes are there from the lower-left corner of an n n square grid to the upper-right corner if we are restricted to traveling only to the right or upward and if we are allowed to touch but not go above a diagonal line form the lower-left corner or the upper-right corner?
• C(2n,n) – C(2n,n-1) = C(2n,n)/(n + 1)
• Catalan numbers: C0 = 1, C1 = 1, C2 = 2, C3 = 5, …
7
• Note
– The rock group “Unhinged Universe” has recorded nvideos whose running times are t1, t2, ..., tn seconds.
– A tape is to be released that can hold C seconds. Since this is the first tape by the Unhinged Universe, the group wants to include as much material as possible.
– The problem is to choose a subset {i1, ..., ik} of {1, 2, ..., n} such that the sum k
j=1tijdoes not exceed C
and is as large as possible.
– For this purpose, we can examine all subsets of {1, 2, …, n} and choose a subset so that the sum does not exceed C and is as large as possible.
8
• Definition– Let = s1s2···sp and = t1t2···tq be strings over {1,
2, ···, n}.– We say that is lexicographically less than
and write < if either (a) p < q and si = ti for i = 1, ..., p, or (b) for some i, si ti, and for the smallest such i, we have si < ti.
• Examples– Determine the lexicographic relation between
and as defined below.• = 132 and = 1324. • = 13246 and = 1342.• = 1324 and = 1342.• = 13542 and = 21354.
9
• Examples– Consider the (lexicographic) order in which the
5-combinations of {1, 2, 3, 4, 5, 6, 7} will be listed. What are the first string, the next string, and the last string?
• 12345, 12346, and 34567
– Find the string that follows 13467 when we list the 5-combinations of X = {1, 2, 3, 4, 5, 6, 7}.
• 13567
– Find the string that follows 2367 when we list the 4-combinations of X = {1, 2, 3, 4, 5, 6, 7}.
• 2456
10
11
12
13
14
• Example– How many strings can be formed using the
following letters?M I S S I S S I P P I
• Solution– Consider the problem of filling 11 blanks with the letters
given:
_ _ _ _ _ _ _ _ _ _ _.
– First, there are C(11,2) ways to choose positions for the two P’s.
– Then, there are C(9,4) ways to choose the remaining positions for the four S’s.
– Finally, there are C(5,4) ways to choose positions for the four I’s.
– C(11,2)·C(9,4)·C(5,4) = (11!/(2!·9!))·(9!/(4!·5!))·(5!/(4!·1!)) = 11!/(2!·4!·4!·1!) = 34,650.
15
• Theorem
– Suppose that a sequence S of n items has n1
identical objects of type 1, n2 identical objects of
type 2, ..., and nt identical objects of type t. Then
the number of orderings of S is n!/(n1!·n2!···nt!).
• Example
– In how many ways can eight distinct books be
divided among three students if Bill gets four
books and Shizuo and Marian each get two
books?
• 8!/(4!·2!·2!) = 420
16
• Example
– Consider three books: a computer science
book, a physics book, and a history book.
Suppose that the library has at least six
copies of each of these books. In how many
ways can we select six books?
• C(8,2) = 28
17
• Theorem– If X is a set containing t elements, the number of
unordered, k-element selections from X, repetitions allowed, is C(k + t – 1, t – 1) = C(k + t– 1, k).
• Example– Suppose that there are piles of red, blue, and
green balls and that each pile contains at least eight balls.
(a) In how many ways can we select eight balls?– C(8+3-1,3-1) = C(10,2) = 45
(b) In how many ways can we select eight balls if we must have at least one ball of each color?
– C(5+3-1,3-1) = C(7,2) = 21
18
• Examples
– In how many ways can 12 identical mathematics books be distributed among the students Anna, Beth, Candy, and Dan?
• C(12+4-1,4-1) = C(15,3) = 455
– How many solutions in nonnegative integers are there to the equation x1 + x2 + x3 + x4 = 29?
• C(29+4-1,4-1) = C(32,3) = 4960
– How many solutions in integers are there in the equation above satisfying x1 > 0, x2 > 1, x3 > 2, x4 0?
• C(23+4-1,4-1) = C(26,3) = 2600
19
• Note
– (a+b)3 = (a+b)(a+b)(a+b)
= aaa + aab + aba + abb + baa + bab + bba + bbb
= a3 + a2b + a2b + ab2 + a2b + ab2 + ab2 + b3
= a3 + 3a2b + 3ab2 + b3
– (a+b)n = C(n,0)anb0
+ C(n,1)an-1b1
+ C(n,2)an-2b2
+ ···
+ C(n,n-1)a1bn-1
+ C(n,n)a0bn
20
• Theorem (Binomial Theorem)– If a and b are real numbers and n is a positive integer,
then (a + b)n = nk=0C(n,k)an-kbk.
– The numbers C(n,r) are known as binomial coefficients.
• Examples– Obtain (a + b)3 using the Binomial Theorem.
– Expand (3x – 2y)4 using the Binomial Theorem.
– Find the coefficient of a5b4 in the expansion of (a + b)9.
• C(9,4) = 126
– Find the coefficient of x2y3z4 in the expansion of (x + y + z)9.
• C(9,2)·C(7,3) = 9!/(2!·3!·4!) = 1260
21
• Note
– Pascal’s triangle
• The border consists of 1’s, and any interior value
is the sum of the two numbers above it.
– Combinatorial identity
• An identity that results from some counting
process
– Combinatorial argument
• The argument that leads to the formulation of a
combinatorial identity
22
• Theorem (Pascal’s Triangle)– C(n + 1,k) = C(n,k – 1) + C(n,k) for 1 k n.
– Proof.• Let X be a set with n elements. Choose a X. Then
C(n + 1,k) is the number of k-element subsets of Y = X {a}. Now the k-element subsets of Y can be divided into two disjoint classes.
1. Subsets of Y not containing a.
2. Subsets of Y containing a.
• The subsets of class 1 are just k-element subsets of Xand there are C(n,k) of these. Each subset of class 2 consists of a (k – 1)-element subset of X together with a and there are C(n,k – 1) of these.
• Therefore, C(n + 1,k) = C(n,k – 1) + C(n,k).
23
• Examples
– Use the Binomial Theorem to derive the
equation nk=0C(n,k) = 2n.
– Show that ni=kC(i,k) = C(n + 1,k + 1).
– Use the equation above to find the sum 1 + 2
+ ··· n.
• 1 + 2 + ··· n
= C(1,1) + C(2,1) + ... + C(n,1)
= C(n + 1,2)
= (n + 1)n/2
24
• Pigeonhole Principle (First Form)– If n pigeons fly into k pigeonholes and k < n,
some pigeonhole contains at least two pigeons.
• Example– Ten persons have first names Alice, Bernard,
and Charles and last names Lee, McDuff, and Ng. Show that at least two persons have the same first and last names.
• Proof.– There are nine possible names for the 10 persons. If we
think of the persons as pigeons and the names as pigeonholes, we can consider the assignment of names to people to be that of assigning pigeonholes to the pigeons. By the Pigeonhole Principle, some name (pigeonhole) is assigned to at least two persons (pigeons).
25
• Pigeonhole Principle (Second Form)
– If f is a function from a finite set X to a finite set Yand |X| > |Y|, then f(x1) = f(x2) for some x1, x2 X, x1 x2.
• Examples
– If 20 processors are interconnected, show that at least two processors are directly connected to the same number of processors.
– Show that if we select 151 distinct computer science courses numbered between 1 and 300 inclusive, at least two are consecutively numbered.
26
• Pigeonhole Principle (Third Form)– Let f be a function from a finite set X into a finite
set Y. Suppose that |X| = n and |Y| = m. Let k = n/m. Then there are at least k values a1, ..., ak X such that f(a1) = f(a2) = ··· = f(ak).
• Example– A useful feature of black-and-white pictures is
the average brightness of the picture. Let us say that two pictures are similar if their average brightness differs by no more than some fixed value. Show that among six pictures, there are either three that are mutually similar or three that are mutually dissimilar.
• Combinations
• Algorithms for
Generating
Permutations
• Generalized
Permutations and
Combinations
Discrete Mathematics, 2008 Computer Science Division, KAIST27
• Binomial Coefficients
and Combinatorial
Identities
• The Pigeonhole
Principle