mat344lecslides-w1-2014

Upload: terry-gao

Post on 02-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Mat344LecSlides-w1-2014

    1/20

    MAT344 Professor S. Tanny

    Enumerative Combinatorics . . . How do I love thee? Let me count

    the ways! (E. B. Browning)

    Count the number of elements in a (finite) set, or the number of ways of

    arranging the elements of finite sets into definite patterns. For example:

    (1) how many ways are there to climb a staircase with 12 stairs if you

    take the stairs either 1 or 2 at a time? (2) how many ways are there

    to arrange the numbers from 1 to 10 around a circle so that no two

    consecutive numbers are adjacent?

    Such questions have ancient roots

    magic squares (China, 2200 BCE) permutations (China, 1100 BCE) n-permutations (Sefer Yetzirah, 200-500 CE)

    (movement of heavenly bodies) Pascal, Fermat (16-17th CE) (games of chance, or gambling)

    1

  • 8/10/2019 Mat344LecSlides-w1-2014

    2/20

    MAT344 Professor S. Tanny

    We begin with some puzzles and games.

    A. In the above, find the fewest number of moves requiredto rearrange the balls from (a) to (b), whereonly 1 ball at a time can be moved.

    Note: Count the number of moves that are required in your solution.

    Be sure to show why the task cannot be accomplished in fewer moves.

    2

  • 8/10/2019 Mat344LecSlides-w1-2014

    3/20

    MAT344 Professor S. Tanny

    B. Tower of Hanoi: There are n rings on Tower 1, each of successivelysmaller size. You are only allowed to move one ring at a time.You can never put a larger ring on top of a smaller ring. Youare allowed to put rings on either of towers 2 or 3 temporarily. Findthe minimum number of moves that are required to transfer all then rings from the first tower to the second tower.

    Note: Is it apparent that this can always be accomplished at all? Why?

    A start at the solution: Let an be the required number. Think small!!

    For n = 1, we have a1 = 1. For n = 2 we can first show that a2 3

    by demonstrating a way to accomplish the task in 3 moves. Then we

    observe that a2 > 2 since we need 2 moves to move the bottom ring.It follows that a2 = 3.

    What is the solution for general n?

    3

  • 8/10/2019 Mat344LecSlides-w1-2014

    4/20

    MAT344 Professor S. Tanny

    C. Game of SIM: In this game there are 6 dots in the plane and 2

    players, Red and Blue. Each player alternately makes a move by joining

    a pair of dots by a line in his (her) colour, either Red or Blue. The

    winner is the first player to form a triangle in a single colour (note:

    the sides of the triangle must originate at the 6 dots, and not at the

    intersections of the interior lines drawn).

    Is this a finite game? What is the maximum number of moves?

    Would you rather go first or second?

    Is there always a winner?

    Is there a winning strategy for either player? If so, for which player?

    Hint: To help you get the idea, think of another game between two

    players that is finite and determine the answers to the above questions

    for that game.4

  • 8/10/2019 Mat344LecSlides-w1-2014

    5/20

    MAT344 Professor S. Tanny

    Basic Counting Rules and Why They Work

    We want to represent the letters of an alphabet with 2 digit binary

    strings. How many different letters can we represent? (This is the

    maximum size of the alphabet.)

    01 102 2 00 11

    Product Rule: If there are n1 ways to do a first thing, and n2 ways to

    do a second (irrespective of the outcome for the first) then there are

    n1 n2 ways to do both things.

    5

  • 8/10/2019 Mat344LecSlides-w1-2014

    6/20

    MAT344 Professor S. Tanny

    Example: How many different Ontario licence plates can be issued, if

    each consists of 3 letters followed by 3 numbers?

    26 26 26 10 10 10

    Think about this variation of the above question: How many different

    Ontario licence plates can be issued, if each consists of 3 letters followed

    by 3 numbers, where the three letters and the three numbers can come

    in any order?

    6

  • 8/10/2019 Mat344LecSlides-w1-2014

    7/20

    MAT344 Professor S. Tanny

    Heres a more formal mathematical approach to the Product Rule.Suppose S is the set of solutions to some combinatorial problem. Sup-

    pose we can write Sas a cross product of two sets, that is, in the formS= S1 S2. Then card (S) = card (S1) card (S2), where card (S) isthe number of elements in S. More generally, if S= S1 S2 . . . Sn,

    then card (S) =n

    i=1

    card (Si).

    Exercise: Find the number of divisors of 21? Of 21,168?(Hint: 21, 168 = 24 33 72).

    Example: We have 16 different books: 5 in Spanish, 4 in French, and7 in English. In how many ways can we choose three books, no two ofthem in the same language?

    Since no two books can be from the same category, we must chooseone book from each category. There are 5 ways to choose a Spanishbook, 4 ways to choose a French book, and 7 ways to choose an Englishbook. Using the product rule, we get 5 4 7 ways.

    7

  • 8/10/2019 Mat344LecSlides-w1-2014

    8/20

    MAT344 Professor S. Tanny

    Example: We have 16 different books: 5 in Spanish, 4 in French, and

    7 in English. In how many ways can we choose a pair of books that are

    not both in the same language?

    There are 3 different possible pairs of books in different languages,

    namely, SF, SE and FE, and our choice will involve exactly one

    of these pairs. First we compute the number of ways we could draw a

    pair of each type. There are 5 Spanish books and 4 French books, sousing the product rule there are 20 different choices for the S F pair.

    Similarly we count the number of choices for the other two pairs. But

    since we can choose only one of these pairs, we choose either SF (20

    ways) or S E (35 ways) or F E (28 ways). So the total number of

    ways is the sum of these. Thus:

    S-F 20S-E 35F-E 28

    838

  • 8/10/2019 Mat344LecSlides-w1-2014

    9/20

    MAT344 Professor S. Tanny

    Sum Rule: If you can do one thing in n1 ways and a second thing in

    n2 ways, there are n1+n2 ways that you can do either first thing or

    second thing, but not both.

    Here is a more formal mathematical approach to the sum rule:

    let S be the set of solutions to some mathematical problem. Suppose

    we can write S = S1 S2, where S1 S2 = . Then card (S) = card(S1)+ card (S2).

    More generally, if we have S =n

    i=1

    Si, and Si Sj = if i = j (that is,

    the sets are pairwise disjoint), then card (S) =n

    i=1card (Si).

    Note: The collection {S1, S2, . . . , S n} is called an n-partition of the setS.

    Exercise: Use mathematical induction to prove the general form of theproduct rule and the sum rule.

    9

  • 8/10/2019 Mat344LecSlides-w1-2014

    10/20

    MAT344 Professor S. Tanny

    Example: How many 3 letter sequences (so order counts) using the

    letters a, b, c, d, e, f are there of the following type:

    a) allow repetitionb) no repetitionc) no repetition and must contain e

    d) allow repetition and must contain e

    a) 63 (product rule)b) 6 5 4 (product rule)c) 60 = (5 4 ) + ( 5 4 ) + ( 5 4) (product and sum rules)d) 63 53 = 91 (What do 63 and 53 each count?)

    Note: You can solve part d) by considering three separate cases,

    i.e., sequences with 1e, 2e, or 3e. Try it!

    10

  • 8/10/2019 Mat344LecSlides-w1-2014

    11/20

    MAT344 Professor S. Tanny

    Exercise: Suppose two baseball teams A and B play a best of five

    series; that is, the winner is the team to first win 3 games. Find the

    number of different possible outcomes in which team A wins the series.

    Represent the winner of a game by its letter. Then any outcome of the

    series in which A wins consists of an arrangement of As and Bs with

    at least 3 As and at most 2 Bs, and where A must be the last letter

    in the sequence.

    If the sequence has only 3 letters, then the sequence consists of 3 As,

    so there is only 1 such sequence. If it has 4 letters, it ends in A and

    there are 3 places to put the single B, so there are 3 sequences in all of

    this type. Finally, if it has 5 letters, it must end in A and there are 2 Bs

    among the first 4 letters. Verify that there are 6 different possibilities.

    Using the sum rule we conclude that there is a total of 10 sequences in

    which A wins the series.11

  • 8/10/2019 Mat344LecSlides-w1-2014

    12/20

    MAT344 Professor S. Tanny

    Permutations

    We now count the number of ways to arrange the elements of a set.Recall that by definition a set contains distinct objects. For example,

    the set S={1, 2, 3, 4} is a set with 4 elements (cardinality 4).

    Sometimes we also count arrangements of multisets. A multiset is a

    collection of not necessarily distinct elements, so it may contain multiple

    copies of the same element. For example, M = {13, 2, 35} denotes amultiset Mcontaining 3 copies of the element 1, a single element 2, and

    5 copies of the element 3. An arrangement of a multiset is equivalent

    to arranging a set but allowing some number of repetitions of one or

    more of the elements.

    Let S be a set with n elements. By the Product Rule there are n! =

    n (n 1) . . . 3 2 1 ways to arrange the elements of S. Further, thereare n(n 1) (n r+ 1) ways to create r-element sequences (that is,arrangements of r of the elements of S) drawn from the n elements of

    S.12

  • 8/10/2019 Mat344LecSlides-w1-2014

    13/20

    MAT344 Professor S. Tanny

    We introduce the following notation:

    Set of the first n positive integers: [n] ={1, 2, , n}

    Alternate way to write n!: nn

    Falling factorial: nr =n(n 1) (n r+ 1) = n!(nr)!

    Rising Factorial: nr =n(n+1) (n+r1) = (n+r1)!(n1)!

    = (n+r1)r

    What is the value of 00?

    By convention, 00 0! = 1. Heres one reason why: by definition, for

    any positive integer n, nn = n(n1)n1. Take n = 1 : 11 = 1 =

    1 00 00 = 1

    13

  • 8/10/2019 Mat344LecSlides-w1-2014

    14/20

    MAT344 Professor S. Tanny

    Counting the Number of Subsets of the Set [n]

    For any nonnegative integer k, a k-subset of [n] is a subset of [n] with

    k elements. If k = 0 then there is only 1 subset, namely, the null set .

    How many k-subsets of [n] are there?

    An example: supposen= 4 and k = 2. We enumerate all the 2-elementsubsets of [4]:

    12 13 1434 23 24

    Thus, there are precisely 6 2-element subsets of [4].

    How can we answer the question in general?

    14

  • 8/10/2019 Mat344LecSlides-w1-2014

    15/20

    MAT344 Professor S. Tanny

    Let x be the number of k-subsets of [n]. By what we showed earlier for

    permutations, we know that each k-subset of [n] can be arranged in k!

    different ways. Thus, xk! counts the number of orderedk-subsets of [n].But any such ordered k-subset is, by definition, just a k-permutation,

    and we know that there are nk k-permutations. Thus we conclude that

    x k! = nk, so x = nk

    k! . Another way of writing this expression is

    n

    k

    ,

    which is called a binomial coefficient and read as n choose k. Finally,from this it follows immediately by algebra that

    n

    k

    = n!

    k!(nk)!.

    What is 34? For n0, what is

    n

    0?

    n

    0

    =

    n0

    00=

    1

    1= 1, n 0

    15

  • 8/10/2019 Mat344LecSlides-w1-2014

    16/20

    MAT344 Professor S. Tanny

    Example: A box contains 7 distinct balls numbered 1 through 7. Three

    balls (1,2,3) are blue, two (4,5) are red, and two (6,7) are green. Find

    the number of selections of three balls which contain at least two blue

    balls.

    Solution 1: Choose the two blue balls in

    32

    = 3 ways. Choose the

    remaining ball from the five remaining balls in

    51

    = 5 ways. By the

    product rule, the answer is 3 5 = 15.

    16

  • 8/10/2019 Mat344LecSlides-w1-2014

    17/20

    MAT344 Professor S. Tanny

    Example: A box contains 7 distinct balls numbered 1 through 7. Three

    balls (1,2,3) are blue, two (4,5) are red, and two (6,7) are green. Find

    the number of selections of three balls which contain at least two blueballs.

    Solution 2: Each selection will be one of the following:

    a) 3 blue balls - 1 way

    b) blue balls (1,2) plus one ball of another colour - 4 ways

    c) blue balls (1,3) plus one ball of another colour - 4 ways

    d) blue balls (2,3) plus one ball of another colour - 4 ways

    Now add these up, using the sum rule, to get 13.

    Which answer is correct, and why?17

  • 8/10/2019 Mat344LecSlides-w1-2014

    18/20

    MAT344 Professor S. Tanny

    The triangle formula is a very important combinatorial identity involvingbinomial coefficients:

    n + 1

    k

    =

    n

    k

    +

    n

    k 1

    We use a combinatorial argument to prove this identity. The strategy

    is to show that both sides of the identity count the same thing in

    different ways.

    By definitions, the left hand side of the identity counts all of the k-subsets of the set [n + 1]. Now we show that the right hand side counts

    these k-subsets too.

    18

  • 8/10/2019 Mat344LecSlides-w1-2014

    19/20

    MAT344 Professor S. Tanny

    Fix your eye on any specific element of [n +1], say the element (n +1).

    For any k-subset of [n + 1], (n + 1) is either in or out of the k-subset.

    But a k-subset of [n + 1] where (n + 1) is out is a k-subset of [n], and

    we know there are

    n

    k

    such k-subsets, so

    n

    k

    counts all the k-subsets

    of [n + 1] where (n + 1) is out.

    Further, any k-subset of [n+1] where (n+1) isinmust contain a unique

    set of k 1 additional elements from [n]. There are

    n

    k 1

    ways to

    choose these k 1 elements so n

    k 1 counts all k-subsets of [n+ 1]

    where (n + 1) is in.

    By the sum rule, the right hand side also counts all the k-subsets of

    [n + 1].19

  • 8/10/2019 Mat344LecSlides-w1-2014

    20/20

    MAT344 Professor S. Tanny

    Here is an algebraic proof of the previous identity. This proof uses the

    factorial definition of the binomial coefficient:n

    k

    +

    n

    k 1

    = n!

    k!(nk)!+ n!

    (k1)!(nk+1)!

    = n!(k1)!(nk)!

    1k

    + 1nk+1

    = n!(k1)!(nk)!

    n+1k(nk+1)

    = (n+1)!k!(nk+1)!

    n + 1

    k

    Notice that this proof does not work for k = 0 or k= n + 1? Why? To

    cover these cases you must do them separately.

    As you can see, the algebraic proof is not nearly as elegant or illuminating

    as the combinatorial proof. In this course we give combinatorial proofs

    whenever we can.20