Slides Chapter2 Counting

Embed Size (px)

Citation preview

  • 7/25/2019 Slides Chapter2 Counting

    1/127

    GEK1505: Chapter 2 Counting

    Chapter 2 Counting 1 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    2/127

    Overview

    1 Geometric series

    2 Arithmetic series

    3 SetsUnion, intersection & complementPrinciple of inclusion & exclusion

    Examples

    4 Counting principlesAddition principleMultiplication rinciple

    5 Arrangements & Combinations

    6 Number of routes on rectangular grid

    7 Pigeonhole Principle

    Chapter 2 Counting 2 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    3/127

    Geometric series

    Definition (Geometric series)

    A geometric series is a sum of the form

    a+ar+ar2 +ar3 + +arn.

    Chapter 2 Counting 3 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    4/127

    Geometric series

    Theorem

    The value of a geometric series is given by the formula

    a+ar+ar2 +ar3 + +arn = a(rn+1 1)r 1 .

    Chapter 2 Counting 4 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    5/127

    Proof. Let

    Sn = a+ar+ar2 +ar3 + +arn. (1)

    Then,

    rSn = ar+ar2 +ar3 +ar4 +

    +arn+1. (2)

    Subtracting (1) from (2), we have

    rSn Sn = arn+1 a

    Sn = a(rn+1

    1)

    r 1 .

    Chapter 2 Counting 5 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    6/127

    Geometric series

    Example (Tower of Hanoi)

    There are three vertical poles A, B, C. Five circular slabs of different radiiand each with a hole in the centre rest on top of each other as shown inthe figure below. What is the minimum number of steps needed totransfer all the slabs to pole Bif at each step no slab is allowed to rest on

    top of a smaller slab in the same pole?

    Chapter 2 Counting 6 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    7/127

    Geometric series

    Solution.Suppose there are only 2 slabs.

    We need minimum number of 3 steps:

    Move the top (smallest) slab to pole C;Move the bottom (larger) slap to pole B;

    Move the smaller slab from pole C to pole B.

    Let an be the minimum number of steps required to move a tower ofn

    slabs. Thena2= 3.

    Chapter 2 Counting 7 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    8/127

    Geometric series

    Suppose there are n slabs.

    Let us label them as 1, 2, etc from the top (smallest) slab to the bottom

    (largest) slab.When can we move the n-th slab to pole B?

    This happens exactly when the first n 1 forms a tower in pole C. The(minimum) number steps to achieve this is an1.

    Chapter 2 Counting 8 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    9/127

    Geometric series

    It takes an1 steps to move the first n 1 slabs to pole C;It takes 1 step to move the n-th slab from pole A to pole B;

    It takes anothera

    n

    1 steps to move then

    1 slabs from poleC

    topole A.

    Hence,

    an = 1 + 2an1.

    Chapter 2 Counting 9 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    10/127

    Geometric series

    In our case, n= 5, so

    a5 = 1 + 2a4

    = 1 + 2(1 + 2a3)

    = 1 + 2 + 22a3

    = 1 + 2 + 22

    (1 + 2a2)= 1 + 2 + 22 + 23a2

    = 1 + 2 + 22 + 23(1 + 2a1)

    = 1 + 2 + 22 + 23 + 24

    = 1(25

    1)2 1

    = 31.

    Chapter 2 Counting 10 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    11/127

    Arithmetic series

    Chapter 2 Counting 11 / 127

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    12/127

    Arithmetic series

    The numbers given by T1, T2, etc are called the triangular numbers.

    T1 = 1T2 = 1 + 2 = 3

    T3 = 1 + 2 + 3 = 6

    T4 = 1 + 2 + 3 + 4 = 10

    Chapter 2 Counting 12 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    13/127

    Arithmetic series

    Theorem

    The triangular numberTn is given by

    Tn = 1 + 2 + 3 + +n =12n(n+ 1).

    Chapter 2 Counting 13 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    14/127

    Arithmetic series

    Proof.

    We rearrange the terms:

    Tn = 1 + 2 + +n 1 +nT

    n = n+n

    1 +

    + 2 + 1

    Adding them:

    2Tn = n(n+ 1)

    Tn = n(n+ 1)

    2

    Chapter 2 Counting 14 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    15/127

    Arithmetic series

    More generally, an arithmetic series is a sum of the form

    a+ (a+d) + (a+ 2d) + + (a+nd).

    The number a is called the first term and the number d is called thecommon difference of the arithmetic series.

    The triangular number Tn is the arithmetic series with

    a=d= 1.

    Chapter 2 Counting 15 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    16/127

    Arithmetic series

    Theorem

    The sum of an arithmetic series is given by

    a+ (a+d) + (a+ 2d) + + (a+nd) =(n+ 1)(2a+dn)2

    .

    Chapter 2 Counting 16 / 127

    A i h i i

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    17/127

    Arithmetic series

    Proof.a+ (a+d) + (a+ 2d) + + (a+nd)

    = (a+ +a) +d(1 + 2 + +n)= (n+ 1)a+dTn

    = (n+ 1)a+dn(n+ 1)

    2

    = (n+ 1)(2a+dn)

    2

    Chapter 2 Counting 17 / 127

    A i h i i

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    18/127

    Arithmetic series

    Proof.

    Alternatively, we rearrange the terms:

    An = (a) + (a+d) + + (a+nd)An = (a+nd) + (a+ (n

    1)d) +

    + a

    Adding them:

    2An = (n+ 1)(2a+nd)

    An = (n+ 1)(2a+nd)

    2

    Chapter 2 Counting 18 / 127

    A i h i i

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    19/127

    Arithmetic series

    Example

    1 + 3 + 5 + + (2n 1) =n2

    .

    1 + 4 + 7 + + (3n 2) = 12n(3n 1).

    Chapter 2 Counting 19 / 127

    A ith ti i

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    20/127

    Arithmetic series

    Example

    Draw n lines in the plane.This will form a number of mutuallynon-overlapping region in the plane. What is the maximum number ofsuch regions that can be formed?

    Chapter 2 Counting 20 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    21/127

    Solution.

    n = 0 1 2 3 4 . . . nRegions = 1 2 4 7 11 . . . ?

    Plus 1 2 3 4 . . . n

    Chapter 2 Counting 21 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    22/127

    Here is an explanation.

    Say when you have 2 lines and want to add a third line. This new thirdline intersects the existing lines and is divided into 3 segments. Eachsegment slices an existing region into 2 and thus we get 3 addition regions.

    Now if you n 1 lines and you want to add the nth line. This new line isdivided into n segments and thus we have n additional regions.

    Chapter 2 Counting 22 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    23/127

    In general, for n lines, we get

    1 + 1 + 2 + 3 + 4 + +n = 1 + (1 + 2 + +n)= 1 +

    1

    2n(n+ 1)

    = 1

    2(n2 +n+ 2).

    Chapter 2 Counting 23 / 127

    Sets

    http://goforward/http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    24/127

    Sets

    Similar objects are often gathered together for easy reference.

    Such a collection is called aset.

    Examples:

    set of all NUS students

    set of positive integers

    Chapter 2 Counting 24 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    25/127

    Sets

    The items in a set are often referred to as elements ormembers of the

    set.Sets are often denoted by uppercase letters like A, B, C etc.

    Notation for sets

    We exhibit members of a set within parentheses, e.g.

    S={a, e, i, o, u} or

    S={x : x is a vowel of the English alphabet}.We use the notation x S to mean x is a member ofS or xbelongsto S.

    xS means x is not a member ofS.

    Chapter 2 Counting 25 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    26/127

    Sets

    Definition (Empty set)

    The empty set is the set containing no members. This is denoted by.That is ={}.

    Think ofas an empty box.

    Chapter 2 Counting 26 / 127

    Sets

    http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    27/127

    Sets

    Definition (Union)

    The union of sets A and Bis the set whose elements are precisely thosebelong to A orB. Symbolically, we denote the union by A

    B:

    A B={x :x A or x B}.

    We can perform the union operation repeatedly to obtain A

    B

    C, etc.

    Chapter 2 Counting 27 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    28/127

    Sets

    Example

    IfA={a, b, c} and B={b, c, d, e}, thenA B={a, b, c, d, e}.

    Chapter 2 Counting 28 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    29/127

    Sets

    Definition (Intersection)

    The intersection of sets A and Bis the set whose elements are preciselythose belong to A and B. Symbolically, we denote the intersection by

    A B:A B={x :x A and x B}.

    We can perform the intersection operation repeatedly to obtain A

    B

    C

    etc.

    Chapter 2 Counting 29 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    30/127

    Sets

    Definition

    We say that the sets A and B aredisjoint if

    A B=.

    Chapter 2 Counting 30 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    31/127

    Sets

    We can useVenn diagrams to visualise the union and intersection of sets:

    Chapter 2 Counting 31 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    32/127

    Theorem (Properties of union & intersection)A B=BA, A B=BA (Commutative law)(A B) C =A (B C) (Associative law)

    (A B) C =A (B C) (Associative law)A (BC) = (A B) (A C) (Distributive law)A (BC) = (A B) (A C) (Distributive law)

    A A= A, A A= A (Idempotent laws)A =A, A =

    Chapter 2 Counting 32 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    33/127

    Example

    Give examples of sets A, B, C such that

    (A B) C=A (BC).

    Solution. Take

    A={1, 2, 3}, B={2, 5}, C ={3, 5}.

    Then

    (A B) C={3, 5}.A (B C) ={1, 2, 3, 5}.

    Chapter 2 Counting 33 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    34/127

    Definition (Subset)

    If every element ofA is also an element ofB, then we say that A is a

    subset ofB.Symbolically, we write

    AB.

    Chapter 2 Counting 34 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    35/127

    Some immediate consequences of the definition of a subset:

    For any set A, AA, A.

    For sets A, B,AA B, A B A.

    IfAB, thenA B=B, A B=A.

    Chapter 2 Counting 35 / 127

    Sets

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    36/127

    We are often interested in subsets of a fixed reference set called theuniversal set.

    Definition (Complement)

    Suppose S is the given universal set, and AS. Then the complementofA, denoted by A

    c

    , is the set consisting of all the elements ofS whichare not in A. That is

    Ac ={x S :xA}.

    By definition,A Ac =S, A Ac =.

    Chapter 2 Counting 36 / 127

    Sets

    http://goforward/http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    37/127

    Theorem (de Morgans laws)

    The following properties hold for setsA, B.

    (A B)c =Ac Bc.

    (A B)c =Ac Bc.

    Chapter 2 Counting 37 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    38/127

    Theorem (PIE for 2 sets)

    For arbitrary finite setsA, B, C, we have

    |A B|=|A| + |B| |A B|.

    The principle is obvious by examining the Venn diagram.

    Chapter 2 Counting 38 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    39/127

    Example

    At Dunman High School there are

    28 students in algebra class,30 students in biology class, and

    8 students in both classes. How many students are in either algebraor biology class?

    Chapter 2 Counting 39 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    40/127

    Solution. LetA= set of students in algebra class

    B= set of students in biology class

    Then|A B|=|A| + |B| |A B|= 28 + 30 8 = 50.

    Chapter 2 Counting 40 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    41/127

    Theorem (PIE for 3 sets)

    For arbitrary finite setsA, B, C, we have

    |AB C|=|A| + |B| + |C| |AB| |A C| |B C| + |AB C|.

    Chapter 2 Counting 41 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    42/127

    Proof.

    |A B C| = |(A B) C|= |A B| + |C| |(A B) C| (3)

    Chapter 2 Counting 42 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    43/127

    Applying PIE for 2 sets, we have

    |A B| = |A| + |B| |A B| (4)

    |(A

    B

    ) C

    | = |(A

    C

    ) (B

    C)|

    = |A C| + |B C| |(A C) (B C)|

    = |A C| + |B C| |(A B C| (5)

    The result follows by substituting (4, 5) into (3).

    Chapter 2 Counting 43 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    44/127

    Example

    At Dunman High School there are

    55 students in either algebra, biology, or chemistry class

    28 students in algebra class

    30 students in biology class

    24 students in chemistry class

    8 students in both algebra and biology

    16 students in both biology and chemistry

    5 students in both algebra and chemistryHow many students attend all three classes?

    Chapter 2 Counting 44 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    45/127

    Solution. Let A= set of students in algebra class

    B= set of students in biology class

    C= set of students in chemistry class

    Then

    |A B C|= 55

    |A

    |= 28,

    |B

    |= 30,

    |C

    |= 24

    |A B|= 8, |B C|= 16, |A C|= 5.

    Chapter 2 Counting 45 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    46/127

    By PIE,

    |AB C|=|A| + |B| + |C| |AB| |A C| |B C| + |AB C|.

    |A BC| = |A B C| |A| |B| |C|+|A B| + |A C| + |BC|

    = 55 28 30 24 + 8 + 16 + 5= 2.

    There are 2 students who attend all three classes.

    Chapter 2 Counting 46 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    47/127

    Example (PIE for 4 sets)

    For arbitrary sets A, B, C, D, we have

    |A B C D|=|A| + |B| + |C| + |D||A B| |A C| |A D| |BC| |BD| |C D|+|A BC| + |A BD| + |A C D| + |B C D||A BC D|.

    Chapter 2 Counting 47 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    48/127

    Solution.

    By PIE for 2 sets,

    |(A

    B

    C)

    D

    | =

    |A

    B

    C

    |+

    |D

    | |(A

    B

    C)

    D

    |By the distributive law,

    |(A

    B

    C)

    D

    | =

    |(A

    D)

    (B

    D)

    (C

    D)

    |

    Chapter 2 Counting 48 / 127

    Principle of Inclusion & Exclusion

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    49/127

    Apply the PIE for 3 sets to calculate

    |A

    B

    C|, |

    (AD)

    (B

    D)

    (C

    D)

    |and rearrange the terms.

    Chapter 2 Counting 49 / 127

    PIE: Examples

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    50/127

    ExampleA pavement was tiled by 80 parallel slabs of tiles. A cat walked along thepavement and at every fifth tile other than the first) i.e. at tiles numbered5, 10, 15, ..., it relieved itself.

    A while later, another cat came along and did the same thing but only atevery seventh tile (other than the first), i.e. at tiles numbered 7, 14, 21, ...

    Later a boy strolled along the pavement, each step covering theodd-numbered tiles.

    How many of the tiles covered by his steps will not have been soiled byany of the two cats?

    Chapter 2 Counting 50 / 127

    PIE: Examples

    http://goforward/http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    51/127

    Solution. Consider the following sets:

    A={1, 2, 3, . . . , 80}, B={5, 10, 15, . . . , 80}

    C={

    7, 14, 21, . . . , 77}, D=

    {1, 3, 5, . . . , 79

    }.

    BC= Set of tiles soiled by any of the two cats(BC)c = Set of ttiles not soiled by any of the two cats

    Goal: Find|D (BC)c|.

    Chapter 2 Counting 51 / 127

    PIE: Examples

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    52/127

    Use the fact that for any set X,

    D= (D X) (D Xc).

    Take X =B C. Then

    |D (B C)c|=|D| |D (B C)|.

    Next, determine|D| and|D (BC)|.

    Chapter 2 Counting 52 / 127

    PIE: Examples

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    53/127

    Clearly,|D|= 40.

    |D (B C)| = |(D B) (D C)| (by distributive law)= |D B| + |D C| |D BC| (by PIE)

    = 8 + 6 1= 13.

    since

    |D B| = |{5, 15, 25, 35, 45, 55, 65, 75}|= 8|D C| = |{7, 21, 35, 49, 63, 77}|= 6

    |D B C| = |{35}|= 1

    Chapter 2 Counting 53 / 127

    PIE: Examples

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    54/127

    Finally,

    |D

    (B

    C)c

    | =

    |D

    | |D

    (B

    C)

    |= 40 13= 27.

    Chapter 2 Counting 54 / 127

    Addition principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    55/127

    Addition principle of counting

    If a choice from set A1 can be made in n1 ways, and a choice from set A2can be made in n2 ways, then the number of choices from A1 orA2 is

    n1+n2.

    Necessary condition: Set A1 and A2 are disjoint.

    Chapter 2 Counting 55 / 127

    Addition principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    56/127

    Addition principle of counting extension

    If a choice from set Aican be made in niways for i= 1, . . . ,m, then thenumber of choices from A1 Am is

    n1+ +nm.

    Necessary condition: The sets A1, . . ., Am are pairwise/mutuallydisjoint, i.e. Ai

    Aj =

    for all i

    =j.

    Chapter 2 Counting 56 / 127

    Addition principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    57/127

    Example

    Given three setsA={a,m, r}B={b, d, i, l, u}C ={c, e, n, t}

    How many ways are there to choose one letter from among the set A, BorC?

    Solution. The three sets are pairwise/mutually disjoint. By the addition

    principle, the number of ways is

    3 + 5 + 4 = 12.

    Chapter 2 Counting 57 / 127

    Addition principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    58/127

    Example

    Here are two sets of positive integers:

    A={2, 3, 5, 7, 11, 13}

    B={2, 4, 6, 8, 10, 12}How many ways are there to choose one integer from A B?

    The two sets are NOT disjoint. What modification can we make to the

    addition principle to accommodate this case?

    Chapter 2 Counting 58 / 127

    Multiplication principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    59/127

    Multiplication principle of counting

    If a task involves a sequence of two steps, where the first step can becompleted in n1 ways and the second step can be completed in n2 ways,then there are

    n1 n2ways to complete the task.

    Necessary condition: The ways each step can be completed areindependentof each other.

    Chapter 2 Counting 59 / 127

    Multiplication principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    60/127

    Multiplication principle of counting extension

    If a task involves a sequence ofm steps, where the i-th step can becompleted in niways, then there are

    n1 nmways to complete the task.

    Necessary condition: The ways each step can be completed are

    independentof each other.

    Chapter 2 Counting 60 / 127

    Multiplication principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    61/127

    Example

    If a word is defined as a juxtaposition of letters, how many

    (i) 2-letter words

    (ii) 3-letter words

    (iii) k-letter words

    can be formed from the English alphabet?

    Chapter 2 Counting 61 / 127

    Multiplication principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    62/127

    Solution. Suppose we wish to form a k-letter word, where k1. Thereare

    26 ways to choose the 1st letter;

    26 ways to choose the 2nd letter;...

    26 ways to choose the k-th letter.

    Each steps above are independent of each other. By the multiplicationprinciple, the total number of ways is

    26 26 k times

    = 26k.

    Chapter 2 Counting 62 / 127

    Arrangements in a row

    E l

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    63/127

    Example

    In how many ways can n different objects be arranged in a row?

    Solution. We choose objects to place in a row one by one from left toright:

    There are n ways for the first position;

    There are n 1 ways for the 2nd position;...

    There are 2 ways for the n 1-th position;There is 1 way for the n-th position.

    By multiplication principle, the number of ways is

    n! =n (n 1) 2 1.

    Chapter 2 Counting 63 / 127

    Arrangements in a row

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    64/127

    Example

    In how many ways can you form a row of 3 different objects from 8different objects?

    Solution. There are

    8 choices for the 1st position;

    7 choices for the 2nd position;

    6 choices for the 3rd position.

    The number of ways is8 7 6 = 336.

    Chapter 2 Counting 64 / 127

    Arrangements in row

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    65/127

    Theorem

    Let nPkbe the number of ways of arranging in a rowkdifferent objectstaken from n different objects. Then

    nPk= n!

    (n k)! .

    Chapter 2 Counting 65 / 127

    Arrangements in a row

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    66/127

    ExampleIn how many ways can you arrange 3 red, 4 green and 5 blue beads in arow?

    Solution. If all the beads were different, then the number of ways is

    (3 + 4 + 5)! = 12!.

    Imagine we have such an arrangement.

    Crucial observation: Permuting the beads of the same colour will yieldthe same arrangement!

    Chapter 2 Counting 66 / 127

    Arrangements in a row

    http://goforward/http://find/http://goback/
  • 7/25/2019 Slides Chapter2 Counting

    67/127

    There are 3! ways to permute the red beads;

    There are 4! ways to permute the green beads;

    There are 5! ways to permute the blue beads.

    By multiplication principle, the number of ways to arrange 3 red, 4 greenand 5 blue beads in a row is

    12!

    3!4!5!.

    Chapter 2 Counting 67 / 127

    Arrangements in a row

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    68/127

    Theorem

    The number of ways of arranging in a rown1 identical objects of Type1,n2 identical objects of Type2, ..., nkidentical objects of Typek is equal to

    (n1+n2+ +nk)!n1!n2! nk! .

    Chapter 2 Counting 68 / 127

    Circular arrangements

    Example

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    69/127

    Example

    In how many ways can you arrange n different objects in a circle?

    Solution.

    A circular arrangement is considered the same after rotating it.

    Chapter 2 Counting 69 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    70/127

    There is no first position.

    Any object can be used as a point of reference.

    Important: Once a reference object is fixed, the order in which theremaining objects are arranged with respect to this reference object (eitherin clockwise or anti-clockwise direction) is now important.

    Chapter 2 Counting 70 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    71/127

    Suppose the objects are labelled as A1, A2, . . ., An.

    Fix A1 as the reference object.

    Arrange the rest in clockwise direction starting from A1.

    Chapter 2 Counting 71 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    72/127

    There are

    (n 1) ways to choose the object next (in clockwise direction) to A1.(n 2) ways to choose the next object (in clockwise direction)....

    2 ways to choose the second last object.

    1 way to choose the last object.

    Therefore, the total number of ways is

    (n 1)! = (n 1) (n 2) 2 1.

    Chapter 2 Counting 72 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    73/127

    Theorem (Circular arrangements)

    The number of ways of arrangingn different objects in a circle is

    (n 1)!.

    Chapter 2 Counting 73 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    74/127

    ExampleFind the number of ways, without removing any empty seat, that 9 guestscan be seated at a round table with exactly 10 seats?

    Solution. The empty seat could be used as the reference object. Thenthe number of ways is just

    (10 1)! = 9!.

    Chapter 2 Counting 74 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    75/127

    Example

    Find the number of ways, without removing any empty seat, that 8 guestscan be seated at a round table with exactly 10 seats?

    Solution. Just imagine, in addition to the existing guests, we have twodifferent ghosts who will occupy the empty seats. Then the the number ofseatings is

    (10

    1)! = 9!.

    Chapter 2 Counting 75 / 127

    Circular arrangements

    Now, let us identify the two ghosts. If there were not identical, there arel i l i h h i i f h

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    76/127

    exactly twocircular arrangements with the same positions for theseghosts! But we want to identify these ghosts as identical since theycorrespond to empty seats.

    Chapter 2 Counting 76 / 127

    Circular arrangements

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    77/127

    Therefore, the total number of ways is

    9!

    2 =

    9

    8

    7!

    2 = 36 7!.

    Chapter 2 Counting 77 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    78/127

    Many counting problems involve counting the number of subsets of a finiteset satisfying certain constraints.

    How many gift hampers can be designed to contain 10 out of 15given different items?

    How many 5-person committees can be formed from a group of 8persons?

    Given n different objects, how many ways can we choose kof them?

    Chapter 2 Counting 78 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    79/127

    Theorem

    Let nCkdenote the number of ways of choosingkobjects from a set ofndifferent objects. Then

    nCk

    = n!

    k!(n k)!.

    Chapter 2 Counting 79 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    80/127

    Proof. For each such a collection ofkobjects, we can arrange them in arow, and there are k! ways to that.

    By multiplication principle,

    n

    Ckk! =

    n

    PkThus,

    nCk=nPk

    k! =

    n!

    k!(n

    k)!

    .

    Chapter 2 Counting 80 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    81/127

    Another notation for nCk is n

    k

    =

    n!

    k!(n k)!

    We pronounce this number as

    n choose k.

    Chapter 2 Counting 81 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    82/127

    The numbers nk also called binomial coefficients since they appear inthe binomial expansion of (1 +x)n:

    (1 +x)2 = 1 + 2x+x2

    (1 +x)3 = 1 + 3x+ 3x2 +x3

    (1 +x)4 = 1 + 4x+ 6x2 + 6x3 +x4

    ...

    (1 +x)

    n

    = n

    0+ n

    1x+ n

    2x2 + + n

    nxn

    Chapter 2 Counting 82 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    83/127

    Theorem (Simple properties of binomial coefficients)n0

    =

    nn

    = 1

    nk

    =

    nnk

    n0+ n1+ n2+ + n

    n= 2n

    Proof. The first two are obvious from the definition.

    The last one follows from the binomial expansion of (1 + x)n by setting

    x= 1.

    Chapter 2 Counting 83 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    84/127

    Example

    How many different 5-member subcommittees can be formed from a9-member specified committee if the President and Vice-President do notserve on the same subcommittee?

    Solution. There are 3 types of subcommittees:

    Type 1: containing President but not Vice President

    Type 2: containing Vice President but not President

    Type 3: not containing President and Vice President

    Chapter 2 Counting 84 / 127

    There are

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    85/127

    74 different subcommittees of Type 1.74

    different subcommittees of Type 2.7

    5

    different subcommittees of Type 3.

    By addition principle, the total number is7

    4

    +

    7

    4

    +

    7

    5

    = 91.

    Chapter 2 Counting 85 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    86/127

    Example

    An LCD display consists of 10 rows and 10 columns of squares which maybe lighted up.

    How many different patterns of lighted display can be obtained if 30squares are lighted up?

    How many of these have at least one lighted square touching the border ofthe display?

    Chapter 2 Counting 86 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    87/127

    There are 100 squares altogether.

    If exactly 30 squares are lighted up, there are

    10030

    different patterns.

    Chapter 2 Counting 87 / 127

    Combinations

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    88/127

    Suppose none of the 30 squares touch the border. The number of these is8 8

    30

    =

    64

    30

    .

    Those have at least one lighted square touching the border is100

    30

    64

    30

    .

    Chapter 2 Counting 88 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    89/127

    ExampleIf you are allowed to go east or north, how many ways can you go from Ato B in the following figure:

    Chapter 2 Counting 89 / 127

    Rectangular grid

    A possible route is given in the following figure in red colour:

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    90/127

    Convert this path into a string of integers consisting of 0s and 1s asfollows:

    Horizontal step corresponds to 0

    Vertical steps corresponds to 1.

    Chapter 2 Counting 90 / 127

    Rectangular grid

    The 01-string corresponds to the path is

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    91/127

    0 1 0 0 1 0 1 0 0.

    The length of this 01-string is always 9, which is the sum of thedimensions of the grid.

    The dimension of the grid here is 3

    6. For this grid, the corresponding01-string always have

    Six 0s

    Three 1s

    Conversely, any 01-string of length 9 will give a path from A to Bconsisting of east or north bound move at each step.

    Chapter 2 Counting 91 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    92/127

    The required number of different routes is equal to the number of different01 string of length 9, with six 0 and three 1.

    Hence, the number required is given by

    9!

    6!3!.

    Chapter 2 Counting 92 / 127

    Rectangular grid

    We label each intersection point on a rectangular grid using coordinate(i,j) such that i increases from left to right, and j increases from bottom

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    93/127

    to top.

    The bottom left point is labelled by (0, 0).

    Chapter 2 Counting 93 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    94/127

    Theorem

    On a rectangular grid, the number of routes from(0, 0) to(i,j) movingeasterly or northerly without back-tracking is

    (i+j)!

    i!j! =

    i+j

    i

    =

    i+j

    j

    .

    Chapter 2 Counting 94 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    95/127

    More generally,

    Theorem

    On a rectangular grid, the number of routes from(i,j) to(k, l), where

    i k and j l, moving easterly or northerly without back-tracking is((k i) + (lj))!

    (k i)!(lj)! =k+l ij

    k i

    =

    k+l ij

    lj.

    Chapter 2 Counting 95 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    96/127

    Example

    How many possible bus routes (moving easterly or northerly without

    back-tracking) are there from (0, 0) to (8, 8) that pass through (3, 3) or(5, 5)?

    Chapter 2 Counting 96 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    97/127

    Solution. Let

    A= set of routes from (0, 0) to (8, 8) and passing through (3, 3).

    B= set of routes from (0, 0) to (8, 8) and passing through (5, 5)

    Aim: Compute

    |A

    B

    |.

    Cha te 2 Co ti g 97 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    98/127

    |A| =

    6

    3

    10

    5

    = 5040

    |B| = 105 6

    3= 5040

    |A B| =

    6

    3

    4

    2

    6

    3

    = 2400.

    Ch t 2 C ti 98 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    99/127

    By PIE,

    |A B| = |A| + |B| |A C|

    = 5040 + 5040 2400= 7680.

    Ch t 2 C ti 99 / 127

    Rectangular grid

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    100/127

    Example

    How many possible bus routes (moving easterly or northerly without

    back-tracking) are there from (0, 0) to (7, 8) thatdoes notpass throughany of the points (3, 3) or (5, 5)?

    Ch t 2 C ti 100 / 127

    Rectangular grid

    Solution.

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    101/127

    A= set of routes from (0, 0) to (7, 8) and passing through (3, 3).

    B= set of routes from (0, 0) to (7, 8) and passing through (5, 5).

    X= set of routes from (0, 0) to (7, 8).

    Aim: Compute|X| |A B|.

    Ch t 2 C ti 101 / 127

    |X| =

    15

    7

    = 6435

    6 9

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    102/127

    |A| = 63 9

    4= 2520|B| =

    10

    5

    5

    2

    = 2520

    |A B| =6

    3

    4

    2

    5

    2

    = 1200

    |X| |A B| = |X| |A| |B| + |A B|= 2595.

    Chapter 2 Counting 102 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    103/127

    Example

    If 3 objects are distributed among 2 pigeon-holes, then there is at least one

    pigeon hole that will contain at least two of the distributed objects.

    Chapter 2 Counting 103 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    104/127

    Theorem (Pigeon-hole Principle (PHP))Supposem objects are distributed amongn pigeon-holes. Ifm>n, thenthere is at leastone pigeon-hole with at leasttwoof the distributedobjects.

    Proof. If every pigeon-hole contains at most one of the distributedobjects, then the total number of the distributed objects is at most n,contradicting the fact that there are more than n objects being

    distributed.

    Chapter 2 Counting 104 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    105/127

    When solving problems using PHP, we need to identify

    what are the pigeon-holes

    what are the distributed objects

    Chapter 2 Counting 105 / 127

    Pigeonhole Principle

    Example

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    106/127

    Jacky takes lunch at the same cafeteria five days a week (Monday toFriday).

    There are 16 different food-stalls.

    Within how many weeks will it be certain that Jacky will take his lunch atleast twice from the same food-stall?

    Distributed objects Pigeon-holes

    days food-stalls

    Chapter 2 Counting 106 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    107/127

    By PHP, a minimum of 17 days guarantees that Jack will order from thesame food-stall on at least two days.

    Thus within 4 weeks, it is certain that he will take his lunch at least twicefrom the same food-stall.

    Chapter 2 Counting 107 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    108/127

    ExampleIf you are at a reception attended by more than 366 guests, you can besure that there will be at least two persons with the same birthday.

    Distributed objects Pigeon-holes

    guests birthdays

    Chapter 2 Counting 108 / 127

    Pigeonhole Principle

    Example

    A fitness club classifies its members according to the following

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    109/127

    characteristics: gender, age, height and weight, for which there are 2, 8, 5and 5 classes respectively.

    If the club has more than 400 members, then there will be at least 2members with exactly the same characteristics.

    Distributed objects Pigeon-holes

    members characteristics

    Total number of characteristics:

    2 8 5 5 = 400.

    Chapter 2 Counting 109 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    110/127

    ExampleA dating agency requires each of its clients to answer a questionnaireconsisting of 10 questions with yes/no options only.

    There are 525 male and 500 female clients.

    Are the following statements true?

    (i) There will be two questionnaires forms with identical answers.

    (ii) There will be one male and one female whose questionnaires answersare identical.

    Chapter 2 Counting 110 / 127

    Pigeonhole Principle

    Solution.

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    111/127

    (i) Yes

    Distributed objects Pigeon-holes

    clients (525 + 500 = 1025) answers (210 = 1024)

    (ii) No.

    It is possible that the identical answers come from both male or both

    female clients.

    Chapter 2 Counting 111 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    112/127

    Theorem (Extended PHP)

    Ifm objects are distributed amongn pigeon-holes andm>n, then therewill beone pigeon-hole which containsat least

    m/n

    objects.

    Here,m/n denotes the smallest integerm/n.

    Chapter 2 Counting 112 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    113/127

    Proof.Let k=m/n. Then k 1< m/nk ornk n

  • 7/25/2019 Slides Chapter2 Counting

    114/127

    ExampleThe members of a youth club are grouped into age groups according to x:

    16x

  • 7/25/2019 Slides Chapter2 Counting

    115/127

    diagonals in the ratio of 2 to 1 (see figure below), and with an area of 680sq km.

    Partition the island into N2 equal rhombic regions by drawing lines parallelto the sides of the rhombus respectively in such a way that each side of

    the rhombus is divided into Nequal segments.

    Assume that there are 3.5 million residents in Singapore. Let N= 10.

    (i) There is at least one rhombic region with population density of at

    least 35000/6.8 residents per sq km.

    (ii) In a gathering of more than 100 residents, there will be at least twopersons who stay within 5.2km of each other.

    Chapter 2 Counting 115 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    116/127

    Let x(in km) be the length of the shorter diagonal of a rhombic region.Then

    N2x2 = 680.

    Chapter 2 Counting 116 / 127

    Pigeonhole Principle

    (i)

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    117/127

    Distributed objects Pigeon-holes

    residents (3, 500, 000) rhombic regions (102 = 100)

    By extended PHP, there is at least one region with at least

    3500000

    100 = 35000

    residents in it.

    Chapter 2 Counting 117 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    118/127

    The area of each region is

    x2 = 680/100 = 6.8 sq km

    There is one region with population density35000

    6.8

    residents per sq km.

    Chapter 2 Counting 118 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    119/127

    (ii) By PHP, in a gathering of more than 100 residents, there will at leasttwo persons who reside in the same region.

    The longest diagonal of the region is

    2x= 26.85.2 km.

    Chapter 2 Counting 119 / 127

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    120/127

    Example

    In any group ofn people there are at least two persons having the samenumber friends. (It is assumed that if a person x is a friend ofy then y isalso a friend ofx.)

    Chapter 2 Counting 120 / 127

    Proof.

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    121/127

    The number of friends of a person x is an integer kwith 0k n 1.If there is a person ywhose number of friends is n 1, then everyone is afriend ofy, that is, no one has 0 friend.

    This means that 0 and n

    1 can not be simultaneously the numbers offriends of some people in the group. The pigeonhole principle tells us thatthere are at least two people having the same number of friends.

    Chapter 2 Counting 121 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    122/127

    ExampleAmong three given integers, there must be two of them whose sum is even.

    Distributed objects Pigeon-holes

    different integers given (3) parity of integer even or odd (2)

    By PHP, there will be two integers with the same parity, and so their sum

    must be even.

    Chapter 2 Counting 122 / 127

    Pigeonhole Principle

    Example

    Classes are conducted from 8 : 00 am to 5 : 00 pm from Monday to Friday

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    123/127

    in one-hour time slots.

    You have 25 hours of classes each week.

    Which of the following statements is true?

    (a) There is one day during which you have at least 5 hours of classes.

    (b) There is one day during which you have at least 6 hours of classes.

    (c) There are at least 2 days in which you have classes with a commontime slot.

    (d) There are at least 3 days in which you have classes with a commontime slot.

    Chapter 2 Counting 123 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    124/127

    Solution.

    Distributed objects Pigeon-holes

    classes (25) days (5)

    (a) True.(b) False.

    Chapter 2 Counting 124 / 127

    Pigeonhole Principle

    Di ib d bj Pi h l

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    125/127

    Distributed objects Pigeon-holes

    classes (25) time slots per day (9)

    By extended PHP, there is one time slot with at least

    25/9 + 1 = 3 classes.

    (c) True.(d) True.

    Chapter 2 Counting 125 / 127

    Pigeonhole Principle

    E l

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    126/127

    ExampleProve that if seven distinct numbers are selected from{1, 2, . . . , 11}, thensome two of these numbers sum to 12.

    Solution. Let

    A1={1, 11}, B={2, 10}, C={3, 9}, D={4, 8},E ={5, 7}, F ={6}.

    Chapter 2 Counting 126 / 127

    Pigeonhole Principle

    http://find/
  • 7/25/2019 Slides Chapter2 Counting

    127/127

    Distributed objects Pigeon-holes

    the seven distinct number selected the sets A, B, C, D, E, F

    By PHP, two of the seven selected numbers must come from the same set.This set cannot be F; so it must be one of the sets A, B, C, D, E. In allcases, these two numbers sum to 12.

    Chapter 2 Counting 127 / 127

    http://find/