1 cs 140 discrete mathematics combinatorics and review notes

25
1 CS 140 Discrete Mathematics Combinatorics And Review Notes

Upload: merilyn-james

Post on 17-Jan-2018

240 views

Category:

Documents


0 download

DESCRIPTION

3 Permutations Permutation of a set of objects: an ordering of the objects in a row. Example: How many permutations are there of the letters i n the word “now”? Positions: ____ ____ ____ Step 1: Choose a letter to put in position 1. Step 2: Choose a letter to put in position 2. Step 3: Choose a letter to put in position 3. So the total number of ways to construct a permutation (which equals the total number of permutations) is 3∙2∙1 = 6. Theorem: The number of permutations of a set of n elements is n !.  3 ways  2 ways  1 way n, o, w

TRANSCRIPT

Page 1: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

1

CS 140 Discrete Mathematics

CombinatoricsAnd Review Notes

Page 2: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

2

Combinatorics

Permutations and r -permutations

Properties of “n choose r”

Pascal’s theorem The binomial theorem Review

Inclusion/exclusion principle

Page 3: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

3

PermutationsPermutation of a set of objects: an ordering of the objects in a row.Example: How many permutations are there of the letters i n the word “now”?Positions:

____ ____ ____ 1 2 3

Step 1: Choose a letter to put in position 1.Step 2: Choose a letter to put in position 2.Step 3: Choose a letter to put in position 3.So the total number of ways to construct a permutation (which equals the total number of permutations) is 3∙2∙1 = 6.

Theorem: The number of permutations of a set of n elements is n !.

3 ways 2 ways 1 way

n, o, w

Page 4: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

4

Definition: An r -permutation of a set of n elements is an “ordered selection” of r elements taken from the set of n elements.Example: How many 3-permutations are there of the letters in the word “DEPAUL”?Solution:

____ ____ ____ 1 2 3

Step 1: Choose a letter to put in position 1.Step 2: Choose a letter to put in position 2.Step 3: Choose a letter to put in position 3.So the total number of 3-permutations that can be formed from the 6 letters is 6∙5∙4 = 120.

r-Permutations

D, E, P, A, U, L

6 ways 5

ways 4 ways

Page 5: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

5

r -Permutations Example: How many r-permutations are there of the symbols x1,x2,x3, . . . ,xn?Solution: ___ ___ ___ ___ ___ 1 2 3 r – 1 rStep 1: Choose a letter to put in position 1.Step 2: Choose a letter to put in position 2. Step r: Choose a letter to put in position r.So the total number of r-permutations that can be formed from x1,x2,x3, . . . ,xn is n∙(n – 1)∙ ∙ ∙ (n – r + 1).

x1, x2, x3, . . . , xn

n ways

n - 1 ways

n – (r - 1) ways

NOTE: n – (r – 1) = n – r + 1

Page 6: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

6

P (n,r)

Notation: P(n,r) = the number of r -permutations of a set of n elements

Theorem: If n and r are integers and n ≥ r ≥ 0, then P (n ,r ) = n (n – 1)(n – 2) ∙ ∙ ∙ (n – r + 1)

or, equivalently, !( , ) .( )!

nP n rn r

Page 7: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

7

More Review

What is ?

Definition: , “n choose r,” is the number of subsets of size

r that can be formed from a set with n elements.

Theorem:

nr

!!( )!

n nr n rr

nr

Page 8: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

8

a. How many distinguishable ways can the letters of the word MISSISSIPPI be arranged?

__ __ __ __ __ __ __ __ __ __ __ 1 2 3 4 5 6 7 8 9 10 11

Step 1: Choose 1 position for the M (Ex: {9})Step 2: Choose 4 positions for the I’s (Ex: {3, 4, 7, 11})Step 3: Choose 4 positions for the S’s (Ex: {1, 2, 6, 10})Step 4: Choose 2 positions for the P’s (Ex: {5, 8})So the answer is

M, I, I, I, I, S, S, S, S, P, P

ways

111

ways

104

ways

64

ways

22

11 10 6 2 11! 10! 6! 2! 11! .(1!)(10!) (4!)(6!) (4!)(2!) (2!)(0!) (1!)(4!)(4!)(2!)1 4 4 2

Page 9: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

9

b. How many distinguishable ways can the letters of the word MISSISSIPPI be arranged if PPI stays together and the string begins with M?

M __ __ __ __ __ __ __ __ 1 2 3 4 5 6 7 8

Step 1: Choose 1 (“long”) position for PPI (Ex: {3})

Step 2: Choose 3 positions for the I’s (Ex: {1, 5, 7})

Step 3: Choose 4 positions for the S’s (Ex: {2, 4, 6, 8})So the answer is

M, PPI, I, I, I, S, S, S, S

ways

81

ways

73

ways

44

8 7 4 8! 7! 4!(1!)(7!) (3!)(4!) (4!)(0!)1 3 4

8! 8 7 6 5 4! 280.(1!)(3!)(4!) (3 2 1)(4!)

Page 10: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

10

Properties of Examples: Use the definition of n choose r to find

a. = the number of subsets of size 1 that can be formed from a set with n elements = n

b. = the number of subsets of size n that can be formed from a set with n elements = 1

c. = the number of subsets of size 0 that can be formed from a set with n elements = 1

nr

1n

nn

0n

Page 11: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

11

Properties of Example: What is

Solution:

nr

nn r

! !( )!( )! ( )! ( )!

! !( )! ! !

( )

( )!

n n r nn n n

n r n rn rnn n

n r

r

r

n

n rr r

Page 12: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

12

Theorem about Theorem: Let n and r be nonnegative integers and suppose r ≤ n. Then

Idea of Proof: Consider a set with 4 elements: {a,b,c,d}. The 2-permutations of the set are

ab, ba, ac, ca, ad, da, bc, cb, bd, db, cd, dc

and there are P (4,2) of them, where P (4,2) = .

nr

!!( )!

n nr n rr

)!24(!4

Page 13: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

13

Proof Idea, cont.: Know P (4,2) =

But: We can also calculate the number of 2-permutations of the set of 4 elements as follows:

Step 1: Choose a subset of 2 elements from the set

Step 2: Order the two elements.

Thus we also have P (4,2) =

Equating the two values of P (4,2) gives

and dividing both sides by 2! gives .

4 2!2

44! 2!(4 2)! 2

4 4!2!(4 2)!2

4!(4- 2)!

ways

42

2! ways

Page 14: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

14

Pascal’s Formula

Let n and r be positive integers and suppose r ≤ n. Then

Proof: Next classExample: Pascal’s Triangle 1 The entry i n row n column r is 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 etc.

1 .1n n n

r r r

.nr

For example,

and so 4 3 3 1 3 4.1 0 1

3 31 and =3,0 1

row 0

row 3

Page 15: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

15

The Binomial Theorem

Given any real numbers a and b and any nonnegative integer n,

, i.e.,

0( )

nn n k k

k

na b a bk

0 0 1 1( ) 0 1

n n n n n nn n na b a b a b a bn

Page 16: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

16

Example: Prove that for all integers n ≥ 0,

Proof: Let n be any integer 0, and apply the binomial theorem with a = 1 and b = 1.Then (1 + 1)n =

But 1 + 1 = 2, and 1 to any power equals 1. So this equation becomes

2 .0 1 2

n n n n nn

0 0 1 1( ) 0 1

n n n n n nn n na b a b a b a bn

02 0 1 2

nn

k

n n n n nk n

01 1 .

nn k k

k

nk

Page 17: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

17

Example: Find (u – 2v)4.Solution: Apply the binomial theorem with n = 4, a = u and b = –2v.

Substitute u for a and (–2v) for b (use parentheses!):

0 0 1 1( ) 0 1

n n n n n nn n na b a b a b a bn

4 4 3 2 2 3 4( ( 2 )) 4 ( 2 ) 6 ( 2 ) 4 ( 2 ) ( 2 )u v u u v u v u v v

4 4 0 0 4 1 1 4 2 2 4 3 3 4 4 44 4 4 4 4( ) 0 1 2 3 4a b a b a b a b a b a b

4 3 2 2 3 4 4 6 4 .a a b a b ab b

4 3 2 2 2 3 3 4 4 8 6 ( 2) ( ) 4 ( 2) ( ) ( 2) ( )u u v u v u v v

4 3 2 2 3 4 8 24 32 16 .u u v u v uv v

4 3 2 2 3 4 8 6 (4)( ) 4 ( 8)( ) (16)( )u u v u v u v v

Note: u – 2v = u + (– 2v)

Page 18: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

18

Cartesian Product of Sets

Definition: Given any sets A and B, we define the Cartesian product of A and B, denoted A B, to be the set of all ordered pairs (a,b) where a is in A and b is in B.

In symbols:A B = { (a,b) | a A and b B }

Example: Let A = {1, 3, 5} and let B = {u, v}. Find A B. Solution: A B = { , , , , , }

(1,u) (1,v)(3,u)(3,v) (5,v)(5,u)

Page 19: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

19

Binary Relations Def: Given any sets What do we mean by a “relation” between two sets?Ex: Let W be the set of all women and P be the set of all people. For any w in W and p in P, we could say “w is related to p” if, and only if, w is the mother of p.Note: An element of W P is an ordered pair (w,p) where w is a woman and p is a person. The elements of some ordered pairs are related; others are not.Def: We define the relation M (for “is the mother of”) as follows: M is the set of all (w,p) in W P such that w is the mother of p. (So M is a subset of W P.)

Page 20: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

20

Definition of Binary Relation

Ex: Let A = {1, 3, 5, 7} and B = {2, 4, 6, 8}. Define a binary relation R from A to B as follows: a R b a > b.

a. Is 3 R 4? Is 5 R 4? Is (7, 2) R ?

b. Write R as a set of ordered pairs. R = {(3, 2), (5, 2), (5, 4), (7, 2), (7, 4), (7, 6)}

Definition: A binary relation R from a set A to a set B is a subset of A B. Given an ordered pair (a, b) in A B, we say that a is related to b, written a R b, if, and only if, (a, b) R. In symbols:

No Yes Yes

a R b (a, b) R

Page 21: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

21

Example of a Binary Relation, cont.

c. Draw an “arrow diagram” to represent R, where R = {(3, 2), (5, 2), (5, 4), (7, 2), (7, 4), (7, 6)}.

Note: An arrow diagram can be used to define a relation.

A B

1357

2468

Page 22: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

22

Definition of Function

Definition: A function f from a set A to a set B is a binary relation from A to B that satisfies the following two properties:1. Every element of A is related by f to some element of B.2. No element of A is related by f to more than one element of B.

Page 23: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

23

Definition of FunctionExample: Which of the relations defined by the following arrow diagrams are functions?

123

uvw

123

uvw

123

uvw

123

uvw

yes

yes

no

no

Page 24: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

24

The Inclusion/Exclusion Rule

Recall: The union of sets S and T, S T, is the set consisting of all the elements of S together with all the elements of T: S T = {x | x S or x T }.

The intersection of sets S and T, S T, is the set consisting of all the elements that are common to both S and T: S T = {x | x S and x T }.

Example: Let A be the set of numbers from 1 to 15 that are divisible by 2 and B be the set of numbers from 1 to 15 that are divisible by 3. What are

N (A)? N (B)? N (A B)? N (A B)? How are these related?

7 5 2 10

10 = 7+ 5 – 2

Page 25: 1 CS 140 Discrete Mathematics Combinatorics And Review Notes

25

Theorem: If A, B, and C are any finite sets, then N (A B) = N (A) + N (B) – N (A B)

andN (A B C) = N (A) + N (B) + N (C)

– N (A B) – N (A C) – N (B C) + N (A B C)

Inclusion/Exclusion Rule

A

C

BA

A B

B

A C

A B

B CA B C

A BA B

C