Section 4.2 Counting

Section 4.2 Counting

Section 4.2 Counting CS 130 – Discrete Structures Counting: Multiplication Principle • The idea is to find out how many members are present in a finite set • Multiplication Principle: If there are n possible outcomes for a first event and m possible outcomes for a second event, then there are n*m possible outcomes for the sequence of two events. • From the multiplication principle, it follows that for 2 sets A and B, |A x B| = |A|x|B| – A x B consists of all ordered pairs with first component from A and second component from B CS 130 – Discrete Structures 27 Examples • How many four digit number can there be if repetitions of numbers is allowed? • And if repetition of numbers is not allowed? • If a man has 4 suits, 8 shirts and 5 ties, how many outfits can he put together? CS 130 – Discrete Structures 28 Counting: Addition Principle • Addition Principle: If A and B are disjoint events with n and m outcomes, respectively, then the total number of possible outcomes for event “A or B” is n+m • If A and B are disjoint sets, then |A B| = |A| + |B| using the addition principle • Example: A customer wants to purchase a vehicle from a dealer. The dealer has 23 autos and 14 trucks in stock. How many selections does the customer have? CS 130 – Discrete Structures 29 More On Addition Principle • If A and B are disjoint sets, then |A B| = |A| + |B| • Prove that if A and B are finite sets then |A-B| = |A| - |A B| and |A-B| = |A| - |B| if B A (A-B) (A B) = (A B) (A B) = A (B B) = A U = A Also, A-B and A B are disjoint sets, therefore using the addition principle, |A| = | (A-B) (A B) | = |A-B| + |A B| Hence, |A-B| = |A| - |A B| If B A, then A B = B Hence, |A-B| = |A| - |B| CS 130 – Discrete Structures 30 Using Principles Together • How many four-digit numbers begin with a 4 or a 5 • How many three-digit integers (numbers between 100 and 999 inclusive) are even? • Suppose the last four digit of a telephone number must include at least one repeated digit. How many such numbers are there? – Use subtraction CS 130 – Discrete Structures 31 Section 4.3: Principle of Inclusion and Exclusion; Pigeonhole Principle CS 130 – Discrete Structures Principle of Inclusion and Exclusion • If A and B are any subsets of a universal set S, then A – B, B – A, and A B are mutually distinct, why? (Draw the Venn Diagram) • We could see that (A-B) (B-A) (A B) is exactly A B • For three disjoint sets – |(A-B) (B-A) (A B)| = |A-B| + |B-A| + |A B| • |A-B| = |A| - |A B| • |B-A| = |B| - |A B| • We finally get: – |A B| = |A| + |B| - |A B| CS 130 – Discrete Structures 33 Inclusion and Exclusion • |A B| = |A| + |B| - |A B| • The above equation represents the principle of inclusion and exclusion • The name comes from the fact that to calculate the elements in a union: – We include the individual elements of A and B – but exclude the elements common to A and B so that we don't count them twice CS 130 – Discrete Structures 34 Example How many integers from 1 to 1000 are either multiples of 3 or multiples of 5 ? We assume that A = {set of all integers from 1-1000 that are multiples of 3} We assume that B = {set of all integers from 1-1000 that are multiples of 5} We have A B = {set of all integers from 1 to 1000 that are multiples of either 3 or 5} A B = {set of all integers that are both multiples of 3 and 5, which is 15} To use the inclusion/exclusion principle to obtain |A B| , we need |A| ,|B| and |A B| From 1 to 1000, every third integer is a multiple of 3,each of this multiple can be represented as 3p, for any integer p from 1 through 333, Hence |A| = 333 Similarly for multiples of 5, each multiple of 5 is of the form 5q for some integer q from 1 through 200. Hence, we have |B| = 200 To determine the number of multiples of 15 from 1 through 1000, each multiple of 15 is of the form 15r for some integer r from 1 through 66. Hence, |A B| = 66 From the principle, we have the number of integer either multiples of 3 or multiples of 5 from 1 to 1000 given by |A B| = 333 + 200 – 66 = 467 CS 130 – Discrete Structures 35 Inclusion/Exclusion Principle for 3 Sets • In a class of students undergoing a computer course the following were observed. – Out of a total of 50 students: – 30 know Java, – 18 know Python, – 26 know C++, – 9 know both Java and Python, – 16 know both Java and C++, – 8 know both Python and C++, – 47 know at least one of the three languages. • From this we have to determine – a. How many students know none of these languages ? – b. How many students know all three languages ? CS 130 – Discrete Structures 36 The Answer a. We know that 47 students know at least one of the three languages in the class of 50. The number of students who do not know any of three languages is given by the difference between the number of students in class and the number of students who know at least one language. Hence, the students who know none of these languages = 50 – 47 = 3 b. Let us assume that – A = All the students who know Java in class. – B = All the students who know Python in the class. – C = All the students who know C++ in class. – So, we need to find |A B C| CS 130 – Discrete Structures 37 The Formula For 3 Sets • We have to derive the inclusion/exclusion formula for 3 sets |A B C| = |A (B C)| = |A| + |B C| - |A (B C)| = |A| + |B| + |C| - |B C| - |(A B) (A C)| = |A| + |B| + |C| - |B C| - (|A B| + |A C| - |A B C|) = |A| + |B| + |C| - |B C| - |A B| - |A C| + |A B C| • We know that: – |B C| = 8 – |A B| = 9 – |A C| =16 – |A B C| = 47 • Hence, using the above formula, we have • 47 = 30 + 26 + 18 -9 -16 -8 + |A B C| • Hence, |A B C| = 6 CS 130 – Discrete Structures 38 General Principle of Inclusion/Exclusion • Given the finite sets A1,……,An, n ≥ 2, then n1 |AA1 ... n | | A i | | AA i j | | AAA i j k | ... ( 1) | AA 1 ... n | 1i n 1 i j n 1 i j k n • In this above equation, the term |Ai A j | 1i j n • Says add together elements in all intersections of the form, where i < j • What are these terms for n=3? CS 130 – Discrete Structures 39 Pigeonhole Principle • If more than k items are placed into k bins, then at least one bin has more than one item from Wikipedia CS 130 – Discrete Structures 40 Pigeonhole Examples • How many people must be in a room to guarantee that two people have the last name begin with the same initial? 26 alphabets hence, have to have 27 people. • How many times must a single die be rolled in order to guarantee getting the same value twice? 6 possible outcomes, hence 7 times. • Assume that in a box there are 10 black socks and 12 blue socks and you need to get one pair of socks of the same color. Suppose you can take socks out of the box one at a time without looking, how many socks do you have to pull out together? 2 colors, hence 3 times. CS 130 – Discrete Structures 41 Section 4.4 Permutations and Combinations CS 130 – Discrete Structures Permutations • An ordered arrangement of objects is called a permutation. – Hence, a permutation of n distinct elements is an ordering of these n elements. • P(n,r) denotes the number of permutations of r distinct objects chosen from n distinct objects • A formula for P(n,r) can be written using the factorial functions, for 0 <= r <= n n! nn ( 1)...( nr 1)( nr )! Pnr(,) nnnr (1)...( 1) nr ! nr ! • Example: 4-digit telephone number without repetition CS 130 – Discrete Structures 43 Special Cases of Permutation • P(n, 0) – P(n, 0) = n! / (n-0)! = n! / n! = 1 – There is only one ordered arrangement of zero objects – the empty set • P(n, 1) – P(n, 1) = n! / (n-1)! = n – There’re n ordered arrangements of one object • P(n, n) – P(n, n) = n! / (n-n)! = n! / 0! = n! – There’re n! ordered arrangements of n distinct objects CS 130 – Discrete Structures 44 Some Examples 1. Ten athletes compete in an Olympic event. Gold, silver and bronze medals are awarded to the first three in the event respectively. How many ways can the awards be made in? Hence, 3 objects from a pool of 10 = P(10,3) = 720 2. How many ways can 6 people be seated on six chairs? P(6,6) = 6! = 720 CS 130 – Discrete Structures 45 More Examples 3. How many permutations of the letters ABCDEF contain the letters DEF together in any order? If DEF is considered as one letter, then we have 4 letters A B C DEF which can be permuted in 4! ways DEF can be ordered by its letters in 3! Ways Hence, by the multiplication principle, total number of orderings possible = 4!*3! = 24*6 = 144 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    32 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us