# Discrete Mathematics - 大葉大學資訊工程系

Document Sample

```					       Discrete
Mathematics

Chapter 5 Counting

大葉大學 資訊工程系 黃鈴玲
§5.1 The Basics of counting
 A counting problem: (Example 15)
Each user on a computer system has a password,
which is six to eight characters long, where each
characters is an uppercase letter or a digit. Each
password must contain at least one digit. How many

 This section introduces
a variety of other counting problems
the basic techniques of counting.

Ch5-2
Basic counting principles
 The sum rule:
If a first task can be done in n1 ways and
a second task in n2 ways, and if these tasks     n1     n2
cannot be done at the same time. then there
are n1+n2 ways to do either task.               n1 + n2 ways

Example 11
Suppose that either a member of faculty or a
student is chosen as a representative to a
university committee. How many different
choices are there for this representative if there
are 37 members of the faculty and 83 students?

Ch5-3
Example 12 A student can choose a computer
project from one of three lists. The three lists contain
23, 15 and 19 possible projects respectively.
How many possible projects are there to choose from?

Sol: 23+15+19=57 projects.

 The product rule:
Suppose that a procedure can be broken down      n1
into two tasks. If there are n1 ways to do the             n1 × n2
ways
first task and n2 ways to do the second task after   n2
the first task has been done, then there are
n1 n2 ways to do the procedure.

Ch5-4
Example 2 The chair of an auditorium (大禮堂) is
to be labeled with a letter and a positive integer
not exceeding 100. What is the largest number of
chairs that can be labeled differently?

Sol: 26 × 100 = 2600 ways to label chairs.
letter 1  x  100
x Ν

Example 4 How many different bit strings are
there of length seven?
Sol: 1 2 3 4          5   6 7
□ □ □ □ □ □ □             → 27 種
↑ ↑ ↑ ↑ ↑ ↑ ↑
0,1 0,1 0,1   ......   0,1

Ch5-5
Example 5
How many different license plates (車牌) are
available if each plate contains a sequence of 3 letters
followed by 3 digits ?

Sol: □ □ □       □ □ □ →263．103

letter      digit

Example 6 How many functions are there from a
set with m elements to one with n elements?
Sol:   a1      b1     f(a1)=? 可以是b1～ bn, 共n種
a2  f   b2    f(a2)=? 可以是b1～ bn, 共n種
．       ．
．       ．        ：
．       ．
am      bn    f(am)=? 可以是b1～ bn, 共n種

∴nm                                             Ch5-6
Example 7 How many one-to-one functions are there
from a set with m elements to one with n element?
(m  n)

Sol:    f(a1) = ? 可以是b1～ bn, 共 n 種
f(a2) = ? 可以是b1～ bn, 但不能= f(a1), 共 n-1 種
f(a3) = ? 可以是b1～ bn, 但不能= f(a1), 也不能=f(a2),
共 n-2 種
：
：
f(am) = ? 不可=f(a1), f(a2), ... , f(am-1), 故共n-(m-1)種
∴共 n．(n-1)．(n-2)．...．(n-m+1)種 1-1 function #

Ch5-7
Example 15 Each user on a computer system has a
password which is 6 to 8 characters long, where each
character is an uppercase letter or a digit. Each
password must contain at least one digit.
How many possible passwords are there?

Sol: Pi : # of possible passwords of length i , i=6,7,8
P6 = 366 - 266
P7 = 367 - 267
P8 = 368 - 268
∴ P6 + P7 + P8 = 366 + 367 + 368 - 266 - 267 - 268種

Ch5-8
Example 14
In a version of Basic, the name of a variable
is a string of one or two alphanumeric characters, where
uppercase and lowercase letters are not distinguished.
Moreover, a variable name must begin with a letter and
must be different from the five strings of two characters
that are reserved for programming use. How many
different variable names are there in this version of
Basic?

Sol:
Let Vi be the number of variable names of length i.
V1 =26
V2 =26．36 – 5
∴26 + 26．36 – 5 different names.
Ch5-9
※ The Inclusion-Exclusion Principle (排容原理)

A B = A  B - A B
A    B

Example 17 How many bit strings of length eight either
start with a 1 bit or end with the two bits 00 ?
Sol:
１２３４５６７８
□□□□□□□□
↑ ↑ ......
① 1 0,1 0,1                       → 共27種
②     . . . . . . . . . . . . 0 0 → 共26種
③ 1 . . . . . . . . . . . 0 0 → 共25種
 27 +26 -25 種                            Ch5-10
※ Tree Diagrams
Example 18         How many bit strings of length four do
not have two consecutive 1s ?
Sol:
0 (0000)
0
1 (0001)
0
0                  0 (0010)     ∴ 8 bit strings
1
0   (0100)
1   0       1   (0101)
0   0       0   (1000)
1
1   (1001)
1      0   (1010)

bit 1       bit 3

Exercise: 11, 17, 23, 27, 38, 39, 47, 53
Ch5-11
Ex 38. How many subsets of a set with 100 elements
have more than one element ?
Sol:      100 100 100              100
(1)                
100  99   98      ...     =  = 2100 - 101
 2 
                            
( 2) a1 , a2 ,..., a100                  Thm. 4 of §4.3

subset:  □,□,..., □       2100 - 101
放  放     放
空集合及
不放 不放    不放                       只有1個元素的集合

Ex 39.    A palindrome (迴文) is a string whose reversal
is identical to the string. How many bit strings
of length n are palindromes ?
( abcdcba 是迴文, abcd 不是 )

Sol: If a1a2 ... an is a palindrome, then    n
a1=an, a2=an-1, a3=an-2, …  2 2  種string.
                Ch5-12
§5.2    The Pigeonhole Principle (鴿籠原理)

Theorem 1 (The Pigeonhole Principle)
If k+1 or more objects are placed into k boxes, then
there is at least one box containing two or more of the
objects.

Proof
Suppose that none of the k boxes contains more than
one object. Then the total number of objects would
be at most k. This is a contradiction.

Example 1. Among any 367 people, there must be
at least two with the same birthday, because there
are only 366 possible birthdays.
Ch5-13
Example 2 In any group of 27 English words, there must
be at least two that begin with the same letter.

Example 3 How many students must be in a class to
guarantee that at least two students receive the
same score on the final exam ? (0~100 points)

Sol:   102.    (101+1)

Theorem 2. (The generalized pigeon hole principle)
If N objects are placed into k boxes, then
N
there is at least one box containing at least  k 
 
objects.

e.g. 21 objects, 10 boxes  there must be one box
containing at least  21 = 3 objects.
 10        Ch5-14
100 
Example 5 Among 100 people there are at least    12  = 9
    
who were born in the same month. ( 100 objects, 12
boxes )

Ch5-15
Def.   Suppose that a1 , a2 ,..., a N is a sequence of numbers.
A subsequence of this sequence is a sequence of
the form ai1 , ai2 ,..., aim where 1  i1  i2  ...  im  N
(i.e., 保持原順序 )

e.g.      sequence: 8, 11, 9, 1, 4, 6, 12, 10, 5, 7
subsequence: 8, 9, 12      ()
9, 11, 4, 6 ()

Def. A sequence is called increasing (遞增) if ai  ai 1
A sequence is called decreasing (遞減) if ai  ai 1
A sequence is called strictly increasing (嚴格遞增) if ai  ai 1
A sequence is called strictly decreasing (嚴格遞減) if ai  ai 1

Exercise: 5, 13, 15, 31                                           Ch5-16
§5.3 Permutations(排列) and Combinations(組合)

Def. A permutation of a set of distinct objects is an ordered
arrangement of these objects. An ordered arrangement of r
elements of a set is called an r-permutation.

Example 2. Let S = {1, 2, 3}.
The arrangement 3,1,2 is a permutation of S.
The arrangement 3,2 is a 2-permutation of S.

Theorem 1. The number of r-permutation of a set with n
distinct elements is P(n, r ) = n  (n - 1)  (n - 2)...( n - r  1) = n!

□ □ □ … □

Example 4. How many different ways are there to select
a first-prize winner (第一名), a second-prize winner, and a
third-prize winner from 100 different people who have
entered a contest ?
Sol:
P(100,3) = 100  99  98

Example 6. Suppose that a saleswoman has to visit
8 different cities. She must begin her trip in a specified
city, but she can visit the other cities in any order she
wishes. How many possible orders can the saleswoman
use when visiting these cities ?
Sol:
7!= 5040

Ch5-18
Def. An r-combination of elements of a set is an
unordered selection of r elements from the set.

Example 9 Let S be the set {1, 2, 3, 4}.
Then {1, 3, 4} is a 3-combination from S.

Theorem 2 The number of r-combinations of a set
with n elements, where n is a positive integer and r is
an integer with 0  r  n, equals

C = C (n, r )
n
r                = (n )
r     =   p ( n,r )
r!
=       n!
r!( n-r )!
稱為 binomial coefficient
pf :
P(n, r ) = C (n, r )  r!

Ch5-19
Example 10. We see that C(4,2)=6, since the
2-combinations of {a,b,c,d} are the six subsets
{a,b}, {a,c}, {a,d}, {b,c}, {b,d} and {c,d}

Corollary 2. Let n and r be nonnegative integers with r  n.
Then C(n,r) = C(n,n-r)

pf : From Thm 2.
n!                  n!
C (n, r ) =            =                          = C (n, n - r )
r!(n - r )! (n - r )! (n - (n - r ))!

組合意義：選 r 個拿走,相當於是選 n - r 個留下.

Ch5-20
Example 12. How many ways are there to select 5
players from a 10-member tennis team to make a trip to
a match at another school ?
Sol: C(10,5)=252

Example 15. Suppose there are 9 faculty members in
the math department and 11 in the computer science
department. How many ways are there to select a
committee if the committee is to consist of 3 faculty
members from the math department and 4 from the
computer science department?

Sol: C (9,3)  C (11,4)

Exercise: 3, 11, 13, 21, 33, 34.

Ch5-21
§5.4         Binomial Coefficients (二項式係數)
Example 1.
( x  y)3 = ( x  y)( x  y)( x  y) = ? x3  ? x 2 y  ? xy2  y 3
要產生 xy2 項時，
需從三個括號中選兩個括號提供 y，剩下一個則提供 x
(注意：同一個括號中的 x 跟 y 不可能相乘)
∴共有 ( 3 )種不同來源的 xy2
2
 xy2 的係數 = ( 3 )       2

∴ ( x  y ) = ( 0 ) x  (1 ) x y  ( 2 ) xy  (3 ) y
3      3    3     3    2        3      2     3     3

Theorem 1. (The Binomial Theorem, 二項式定理)
Let x,y be variables, and let n be a positive integer, then
n
( x  y) n = (0 ) x n  (1 ) x n-1 y  ...  ( n-1 ) xyn-1  ( n ) y n =  ( nj ) x n- j y j
n          n
n               n
j =0

Ch5-22
Example 4.            What is the coefficient of x12y13 in
the expansion of (2 x - 3 y ) ?
25

Sol:         (2 x - 3 y ) 25 = (2 x  (-3 y )) 25

∴      (13 )  212  (-3)13
25

Cor 1.       Let n be a positive integer. Then
n

k
( n ) = ( 0 )  (1 )  ...  ( n ) = 2 n
k =0
n      n
n

pf : By Thm 1, let x = y = 1
(1  1) n = ( 0 )  (1 )  ( n )  ...  ( n )
n      n
2             n

n

Cor 2.       Let n be a positive integer. Then  ( -1) k ( n ) = 0
k
k =0

pf : by Thm 1. (1-1)n = 0
Ch5-23
Theorem 2. (Pascal’s identity)
Let n and k be positive integers with n  k
Then
 n  1  n   n 
 k  =  k - 1   k 
              
              

PASCAL’s triangle
(0 )
0                                          1
(1 )
0             (1 )
1
1       1
2            2             2
1       2       1
( )          ( )           ( )
0            1             2
1       3       3       1
(3 )          3
(1 )          (3 )          (3 )   1       4       6       4       1
0                          2             3

…
…

4
(3 )

Ch5-24
 n  1  n   n 

 k  =  k - 1   k 
        
pf : ①(algebraic proof, 代數證明)                                                

 n  1 = (n  1)!
 k 
       k!(n  1 - k )!
 n   n =          n!

n!
 k - 1  k 
         (k - 1)! (n - k  1)! k!(n - k )!
k  n!      (n - k  1)  n!   (n  1)  n!
=                                   =
k!(n - k  1)! k!(n - k  1)! k!(n - k  1)!

②(combinatorial proof, 組合意義證明):
n       1                n 1         n   1
‧   取法             ‧    +        ‧
      n  1 =  n  1    n 1
=                                        k   k - 1 0   k 1
                
k                    k 0        k-1 1
Ch5-25
Theorem 3.          (Vandermode’s Identity)
m, n, r    , 0  r  m, n
r
C (m  n, r ) =  C (m, r - k )  C (n, k )
k =0

pf :
m       n
mn    mn        mn
C(m+n, r) =                         =        ↓ ↓ + ↓ ↓ +...+ ↓ ↓
r, 0 r-1, 1     0, r
r
=  m  n    m  n   ...  m  n 
 r  0   r - 1 1         0  r 
                         
r
=  C (m, r - k )  C (n, k )
k =0
Ch5-26
Ex 33. Here we will count the number of paths
between the origin (0,0) and point (m,n) such
that each path is made up of a series of
steps, where each step is a move one unit
to the right or a more one unit upward.
1     4    10   20   35 56 (5,3)             Each path can be represented by a
bit string consisting of m 0s and n 1s.
1     3    6    10   15 21
(→)       (↑)
1     2    3    4      5        6         Red path對應的字串: 0 1 1 0 0 0 1 0

(0,0)     1   1     1     1        1                  5  3  = 8! = 56
 5 
        5!3!

 m  n
There are        n 
             paths of the desired type.
      

Exercise: 7, 21, 28                                                          Ch5-27

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 16 posted: 3/22/2012 language: pages: 27