1 Lecture 4 (part 1) Combinatorics Reading: Epp Chp 6.

Slides:



Advertisements
Similar presentations
Counting. Counting = Determining the number of elements of a finite set.
Advertisements

Counting Techniques: Permutations of Selected Elements Addition Rule, Difference Rule, Inclusion/Exclusion Rule.
Main Menu Main Menu (Click on the topics below) Combinations Example Theorem Click on the picture.
Recursively Defined Functions
Counting and Probability The outcome of a random process is sure to occur, but impossible to predict. Examples: fair coin tossing, rolling a pair of dice,
Multiplication Rule. A tree structure is a useful tool for keeping systematic track of all possibilities in situations in which events happen in order.
Discrete Structures Chapter 4 Counting and Probability Nurul Amelina Nasharuddin Multimedia Department.
Discrete Mathematics Lecture 7 More Probability and Counting Harper Langston New York University.
1 Section 4.1 Basics of Counting. 2 Basic Counting Principles: Sum Rule Suppose you have two tasks to perform: –The first task can be done in n 1 ways;
CSE115/ENGR160 Discrete Mathematics 04/10/12
CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.
Counting and probability What do you mean by counting? How do you count things in daily life? Counting the European way or the English speaking way?
Combinations We should use permutation where order matters
Discrete Mathematics Lecture 5
Discrete Mathematics Lecture 6 Alexander Bukharovich New York University.
1 More Counting Techniques Possibility trees Multiplication rule Permutations Combinations.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Mathematics. Permutation & Combination Session.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Combinatorics 3/15 and 3/ Counting A restaurant offers the following menu: Main CourseVegetablesBeverage BeefPotatoesMilk HamGreen BeansCoffee.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Copyright © Cengage Learning. All rights reserved. CHAPTER 9 COUNTING AND PROBABILITY.
Introduction to Counting Discrete Structures. A Multiplication Principle.
Counting. Techniques for counting Rule 1 Suppose we carry out have a sets A 1, A 2, A 3, … and that any pair are mutually exclusive (i.e. A 1  A 2 =
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Binomial Coefficients, Inclusion-exclusion principle
9.3 Addition Rule. The basic rule underlying the calculation of the number of elements in a union or difference or intersection is the addition rule.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Methods of Counting Outcomes BUSA 2100, Section 4.1.
NO ONE CAN PREDICT TO WHAT HEIGHTS YOU CAN SOAR
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Chapter 6, Counting and Probability
Objectives Solve counting problems using the Multiplication Rule Solve counting problems using permutations Solve counting problems using combinations.
1 Lecture 4 (part 2) Combinatorics Reading: Epp Chp 6.
Sullivan Algebra and Trigonometry: Section 14.2 Objectives of this Section Solve Counting Problems Using the Multiplication Principle Solve Counting Problems.
The Basics of Counting Section 6.1.
Section Section Summary The Product Rule The Sum Rule The Subtraction Rule The Division Rule Examples, Examples, and Examples Tree Diagrams.
Week 11 What is Probability? Quantification of uncertainty. Mathematical model for things that occur randomly. Random – not haphazard, don’t know what.
CS 103 Discrete Structures Lecture 16
Discrete Mathematics, 1st Edition Kevin Ferland Chapter 6 Basic Counting 1.
1 Section 6.5 Inclusion/Exclusion. 2 Finding the number of elements in the union of 2 sets From set theory, we know that the number of elements in the.
Counting Principles Multiplication rule Permutations Combinations.
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
Spring 2016 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Section Basic Counting Principles: The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n 1.
CS 104: Discrete Mathematics
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 5 Counting 歐亞書局.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Section 6.3. Section Summary Permutations Combinations.
Discrete Mathematics Lecture 8 Probability and Counting
ICS 253: Discrete Structures I
COCS DISCRETE STRUCTURES
12.2 Permutations and Combinations
9. Counting and Probability 1
Permutations and Combinations
Recursively Defined Functions
CS100: Discrete structures
COUNTING AND PROBABILITY
Set, Combinatorics, Probability & Number Theory
Permutations and Combinations
Basic Counting.
COUNTING AND PROBABILITY
Discrete Structures Counting.
Representations of Integers
Presentation transcript:

1 Lecture 4 (part 1) Combinatorics Reading: Epp Chp 6

2 Outline 1.Basic Rules a)Linear Series Rule b)Multiplication Rule c)Addition and Difference Rule d)Inclusion-Exclusion Rule 2.Common Counting Scenarios a)Permutations (Ordered Selections) b)Combinations (Unordered Selections) c)Counting ordered partitions / permutations of multi-sets 3.Algebra of Combinations 4.Binomial Theorem

3 1. Basic Rules 1.1 Linear Series Rule. If m and n are integers such that m  n, then there are n-m+1 integers from m to n inclusive. Example 1: How many integers are there in the sequence 10, 11, 12, …, 19, 20 ? Ans: 20 – = 11 Example 2: How many integers are there in the sequence -8,-7,-6,…-1,0,1,2,…4, 5 ? Ans: 5 – (–8) + 1 = 14

4 1. Basic Rules 1.1 Linear Series Rule. If m and n are integers such that m  n, then there are n-m+1 integers from m to n inclusive. Example 3: How many integers are there in 0 to 1000 inclusive, that are divisible by 3. The integers are 0,3,6,9,…,996,999, which are in the form 3k, where k = 0,1,2,…,333. Hence there are = 334 integers from 0 to 1000 which are divisible by 3.

5 1. Basic Rules: Multiplication Rule 1.2 Multiplication Rule If an operation consists of a sequence of steps/events E 1, E 2 … E k and if each E i can be performed in n i ways regardless of how the previous steps E 1, … E i-1 were performed (i.e. independent), then the entire operation can be performed in n 1  n 2  …  n k ways. Proof of multiplication rule is by induction (Left as an exercise)

6 1. Basic Rules: Multiplication Rule 1.2 Multiplication Rule If an operation consists of a sequence of steps/events E 1, E 2 … E k and if each E i can be performed in n i ways regardless of how the previous steps E 1, … E i-1 were performed (i.e. independent), then the entire operation can be performed in n 1  n 2  …  n k ways. Example 1: At breakfast, you are given a choice of coffee or tea, and a choice of a scrambled, fried and boiled egg. How many different kinds of breakfast can you have? Scrambled Fried Boiled Scrambled Fried Boiled Coffee Tea Ans: Step 1: Choose coffee or tea => 2 ways Step 2: Choose how you would like your egg to be done => 3 ways regardless of the choice made in step 1. Total number of ways = 2 x 3 = 6 ways (Mul. Rule)

7 1. Basic Rules: Multiplication Rule Example 2: Let A and B be finite sets. If |A| = m and |B| = n, how many elements are there in (i) A  B  ? (ii) P(A) ? (i) The task of selecting pairs for A  B is reduced to the following steps: Step 1: Choose an element x from A : m ways. Step 2: Choose an element y from B : n ways regardless of choices made in step 1. Total number of ways of performing the task = total number of elements in A  B = m  n (Multiplication Rule)

8 1. Basic Rules: Multiplication Rule (ii) Let the elements of A be a 1, a 2, a 3,…, a m The task of forming a subset of A is reduced to the following procedure: Step 1: Either take or drop element a 1 : 2 ways. Step 2: Either take or drop element a 2 : 2 ways regardless of choices made in step 1. Step 3: Either take or drop element a 3 : 2 ways regardless of choices made in steps 1 and 2. … Step m : Either take or drop element a m : 2 ways regardless of choices made in steps 1, 2, 3, 4, …, m-1. Total number of ways of performing the task (by multiplication rule) = 2  2  2  …  2 Example 2: Let A and B be finite sets. If |A| = m and |B| = n, how many elements are there in (i) A  B  ? (ii) P(A) ? m times of 2 = 2 m

9 1. Basic Rules: Multiplication Rule Example 3: A car license plate has 3 letters of alphabet followed by 4 single digit numbers. How many different car licenses can be issued (a) if repetitions of alphabets/numbers in the license plate is allowed; (b) if repetitions are not allowed? Ans (a): The task of forming a license plate number consists of the following sub-tasks: Step 1: choose the 1 st letter : 26 ways. Step 2: choose the 2 nd letter : 26 ways (independent of step 1). Step 3: choose the 3 rd letter : 26 ways (independent of steps 1-2). Step 4: choose the 1 st digit : 10 ways (independent of steps 1-3). Step 5: choose the 2 nd digit : 10 ways (independent of steps 1-4). Step 6: choose the 3 rd digit : 10 ways (independent of steps 1-5). Step 7: choose the 4 th digit : 10 ways (independent of steps 1-6). Total number of performing the task = 26 3  10 4

10 1. Basic Rules: Multiplication Rule Example 3: A car license plate has 3 letters of alphabet followed by 4 single digit numbers. How many different car licenses can be issued (a) if repetitions of alphabets/numbers in the license plate is allowed; (b) if repetitions are not allowed? Ans (b): The task of forming a license plate number consists of the following sub-tasks: Step 1: choose the 1 st letter : 26 ways. Step 2: choose the 2 nd letter : 25 ways (independent of step 1). Step 3: choose the 3 rd letter : 24 ways (independent of steps 1-2). Step 4: choose the 1 st digit : 10 ways (independent of steps 1-3). Step 5: choose the 2 nd digit : 9 ways (independent of steps 1-4). Step 6: choose the 3 rd digit : 8 ways (independent of steps 1-5). Step 7: choose the 4 th digit : 7 ways (independent of steps 1-6). Total number of performing the task = 26  25  24  10  9  8  7

11 1. Basic Rules: Multiplication Rule Example 4: (Limitations of the Multiplication Rule) Two teams A and B are to play each other repeatedly until one wins two games in a row, or until a total of 3 games. How many ways can a tournament be played? n Incorrect answer: Step 1: Either A wins or B wins : 2 ways. Step 2: Either A wins or B wins : 2 ways. Step 3: Either A wins or B wins : 2 ways. Total number of ways = 2  2  2 dependent

12 1. Basic Rules: Multiplication Rule Example 4: (Limitations of the Multiplication Rule) Two teams A and B are to play each other repeatedly until one wins two games in a row, or until a total of 3 games. How many ways can a tournament be played? n The above example illustrates a situation when the multiplication rule cannot be used. A winsB wins A winsB wins A winsB wins A winsB wins A winsB wins n This is because the subsequent events (games) are dependent on the outcome of the previous events.

13 1. Basic Rules: Multiplication Rule Example 5: (Goal Re-ordering is a possible way to by-pass dependency of tasks) Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? Incorrect answer: Selecting three officers can be broken down to the following tasks: Step 1: Select the president : 3 ways. Step 2: Select the treasurer : 3 ways. Step 3: Select the secretary : 2 ways. Total number of performing the task = 3  3  2 ways dependent

14 1. Basic Rules: Multiplication Rule Example 5: (Goal Re-ordering is a possible way to by-pass dependency of tasks) Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? C D A Step 1: Select the president: 3 ways Step 2: Select the treasurer: number of ways DEPENDENT on the outcome of step 1!!! A B A B D C D C D D C C Step 3: Select the secretary: number of ways DEPENDENT on the outcome of step 2, which is in turn, DEPENDENT on step 1. start B C D

15 1. Basic Rules: Multiplication Rule Example 5: (Goal Re-ordering is a possible way to by-pass dependency of tasks) Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? Answer: Independence of events can sometimes be restored through the re-ordering of your tasks. Step 1: Select the secretary : 2 ways (C or D). Step 2: Select the president : 2 ways regardless of the choice taken in step 1 (person B with the remaining person from step 1) Step 3: Select the treasurer : 2 ways. (person A with the person remaining from step 2) Total number of performing the task = 2  2  2 ways

16 1. Basic Rules: Multiplication Rule Example 5: (Goal Re-ordering is a possible way to by-pass dependency of tasks) Three officers – A president, a treasurer, and a secretary, are to be chosen from among 4 people: A, B, C, D. Suppose that A cannot be president, and either C or D must be secretary. How many ways can the officers be chosen? Step 1: Select the secretary: 2 ways Step 2: Select the president: 2 ways Step 3: Select the treasurer: 2 ways B D B C A D A B A C A B start C D

17 1. Basic Rules: Multiplication Rule Summary: n Always check that the number of ways of each step is independent of the choices of the previous steps. n The multiplication rule did NOT say : ‘Each step is independent of the choices of previous step’. It says : ‘The number of ways of each step is independent of the choices of the previous step’ Get the subtle difference? n Goal re-ordering may help.

18 1. Basic Rules: Addition/Difference Rule 1.3Addition Rule: If a finite set A = A 1  A 2  A n where all the A i ’s are mutually disjoint, then |A| = |A 1 | + |A 2 | +  + |A n | Difference Rule: If A is a finite set and B  A, then |A – B| = |A| – |B| Addition Rule is proven by induction. (Proof are left as exercise). Difference Rule is a corollary of the addition rule. (‘corollary’ meaning that ‘it is a result of’… meaning that you can prove/infer the difference rule from the addition rule.) Because when B  A, ( A – B ) and B form a partition of A (Meaning that ( A – B )  B = A and ( A – B )  B =  ) Therefore by addition rule: |A – B| + |B| = |A| And so: |A – B| = |A| – |B| A B

19 1. Basic Rules: Addition/Difference Rule Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible? Answer: n The set of all code words can be partitioned into subsets consisting of those of length 1, length 2, and length 3. Set of all code words of length  3 Set of all code words of length 1 Set of all code words of length 2 Set of all code words of length 3 By addition rule: |Set of all code words of length  3| = | Set of all code words of length 1 | + | Set of all code words of length 2 | + | Set of all code words of length 3 |

20 1. Basic Rules: Addition/Difference Rule Example 1: A computer access code word consists of one to three letters, chosen from the 26 alphabets, with repetitions allowed. How many code words are possible? Answer: n The set of all code words can be partitioned into subsets consisting of those of length 1, length 2, and length 3. Set of all code words of length  3 Set of all code words of length 1 Set of all code words of length 2 Set of all code words of length 3 n Number of code words of length 1 = 26 n Number of code words of length 2 = 26 2 (Multiplication Rule) n Number of code words of length 3 = 26 3 (Multiplication Rule) n Total number of code words = (Addition Rule)

21 1. Basic Rules: Addition/Difference Rule Example 2: There are 15 different computer science books, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject? Answer: Set of selections of 2 books 1 book from CS and 1 book Math 1 book from CS and 1 book from Chemistry 1 book from Math and 1 book from Chemistry n By addition rule: |Set of selections of 2 books| = | Set of selection of 1 book from CS and 1 book from Math | + | Set of selection of 1 book from CS and 1 book from Chem | + | Set of selection of 1 book from Math and 1 book from Chem |

22 1. Basic Rules: Addition/Difference Rule Example 2: There are 15 different computer science boks, 12 different math books, and 10 different chemistry books on the shelf. How many ways can we select 2 books, each from a different subject? Answer: Set of selections of 2 books 1 book from CS and 1 book Math 1 book from CS and 1 book from Chemistry 1 book from Math and 1 book from Chemistry 15  12 (M.R.) 15  10 (M.R.) 12  10 (M.R.) ++ Addition rule is reasoning-by-cases applied to counting!

23 1. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8!  (by multiplicaton rule) How? Step 1: Sit the 1 st person: 8 ways Step 2: Sit the 2 nd person: 7 ways regardless of outcome of step 1. Step 3: Sit the 3 rd person: 6 ways regardless of outcome of step 1-2. … Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart

24 1. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8! Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart = 2  7! (by multiplicaton rule) How? Step 1: Sit the 2 enemies together: 2  7 ways Step 2-7: Sit the remaining 6 people: 6  5  4  3  2  1 Step 1: Combine the 2 enemies as 1 person and take it as an arrangement of 7 people to 7 chairs, (7!). Step 2: Different ways of arranging the 2 enemies to sit side-by-side: 2 ways. OR… Another way of looking at it:

25 1. Basic Rules: Addition/Difference Rule Example 3: A group of eight people are attending the movies together. If two of the eight people are enemies and do not want to sit next to each other, how many ways can this group sit in a row, such that the two enemies are separated? Answer: Different arrangements of 8 people in a row = 8! Different arrangements of 8 people in a row where the 2 enemies sit next to each other Different arrangements of 8 people in a row where the 2 enemies sit apart = 2  7! (by multiplicaton rule) Answer = 8! – 2  7! (Difference Rule)

26 1. Basic Rules: Addition/Difference Rule Example 4: How many integers are there in 1000 to 9999 that contain at least a digit 5. Answer =Number of integers in 1000 to 9999 – Number of integers in 1000 to 9999 that do not contain a digit 5. (Difference Rule) =(9999 – ) – ( Linear Series Rule) (Multiplication Rule) =2439

27 1. Basic Rules: Addition/Difference Rule Example 5: How many 3 digit numbers have at least one digit repeated? Answer =Number of 3 digit numbers – Number of 3 digit numbers which have NO digit repeated (Difference Rule) (9  10  10) Multiplication Rule: Step 1: Choose hundreths digit (must exclude leading ‘0’, therefore only 9 ways) Step 2: Choose tenths digit Step 3: Choose units digit (9  9  8) Multiplication Rule: Step 1: Choose hundreths digit (must exlude leading ‘0’) Step 2: Choose tenths digit (10 ways, excluding the digit in step 1. Therefore 9 ways) Step 3: Choose units digit

28 1. Basic Rules: Inclusion-Exclusion Rule 1.4Inclusion-Exclusion Rule: (For 2 sets) Given any sets A and B, |A  B| = |A| + |B| – |A  B| (For 3 sets) Given any sets A, B and C, |A  B  C | = |A| + |B| + |C| – |A  B| – |A  C| – |B  C| + |A  B  C| (For n sets) Given any sets A 1 … A n, | A 1  …  A n | = | A i | – | A i  A j | + | A i  A j  A k | –… i  1..n  i,j  1..n  i,j distinct i,j,k  1..n  i,j,k distinct

29 1. Basic Rules: Inclusion-Exclusion Rule n Moral of the story behind the inclusion- exclusion rule: –If you over-count, then subtract away those you counted more than once. –If you under-count, then add back those you have missed out. This is applicable to any counting scenario. n Inclusion-Exclusion Rule is the generalized version of the addition rule. If the sets are disjoint, then the In-Ex rule reduces to the addition rule.

30 1. Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Answer: |{Integers of multiples of 3 or 5}| = |{Integers of multiples of 3}| + |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule) All integers from 1 to 1000 Multiples of 5 Multiples of 3

31 1. Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Answer: |{Integers of multiples of 3 or 5}| = |{Integers of multiples of 3}| + |{Integers of multiples of 5}| – |{Integers of multiples of 3 and 5}| (Inclusion-Exclusion Rule) |{Integers of multiples of 3}| = |{3k | where k = 1,2,…333}| = 333 |{Integers of multiples of 5}| = |{5k | where k = 1,2,…200}| = 200 |{Integers of multiples of 3 and 5}| = |{15k | where k = 1,2,…66}| = 66 Ans = – 66= 467

32 1. Basic Rules: Inclusion-Exclusion Rule Example 1: How many integers from 1 through 1000 are multiples of 3 or 5? How many are neither multiples of 3 nor 5? Question: How many are neither multiples of 3 nor 5? Answer: {Int from with are multiples of 3 or 5}  {Int from } Ans= (By difference rule) =

33 1. Basic Rules: Inclusion-Exclusion Rule Example 2: In a class of 50 students, 30 know Pascal, 18 know Fortran, 26 know COBOL, 9 know both Pascal and Fortran, 16 know Pascal and COBOL, 8 know both Fortran and COBOL, 47 knows at least one of the three languages. (a) how many students know none of the three languages? (b) how many students know all three languages? (c) how many students know Pascal and Fortran but not COBOL? (d) how many students know Pascal, but neither Fortran nor COBOL? P = set of students who know Pascal; C = set of students who know COBOL F = set of students who know Fortran; U = All 50 students. (a)|U – (P  C  F)| = |U| – |(P  C  F)| (By difference rule, since (P  C  F)  U) |U| = 50 (Given) |(P  C  F)| = 47 (Given) Therefore answer = = 3.

34 1. Basic Rules: Inclusion-Exclusion Rule Example 2: In a class of 50 students, 30 know Pascal, 18 know Fortran, 26 know COBOL, 9 know both Pascal and Fortran, 16 know Pascal and COBOL, 8 know both Fortran and COBOL, 47 knows at least one of the three languages. (a) how many students know none of the three languages? (b) how many students know all three languages? (c) how many students know Pascal and Fortran but not COBOL? (d) how many students know Pascal, but neither Fortran nor COBOL? P = set of students who know Pascal; C = set of students who know COBOL F = set of students who know Fortran; U = All 50 students. (b)|(P  C  F)| = |P| + |C| + |F| – |P  C| – |P  F| – |C  F| + |P  C  F| (Inclusion-Exclusion Rule for 3 sets) 47 = – 9 – 16 – 8 + |P  C  F| |P  C  F| = 6

35 1. Basic Rules: Inclusion-Exclusion Rule Example 2: In a class of 50 students, 30 know Pascal, 18 know Fortran, 26 know COBOL, 9 know both Pascal and Fortran, 16 know Pascal and COBOL, 8 know both Fortran and COBOL, 47 knows at least one of the three languages. (a) how many students know none of the three languages? (b) how many students know all three languages? (c) how many students know Pascal and Fortran but not COBOL? (d) how many students know Pascal, but neither Fortran nor COBOL? P = set of students who know Pascal; C = set of students who know COBOL F = set of students who know Fortran; U = All 50 students. (c)|((P  F) –  (P  F  C))| = |P  F| – |P  F  C|(Difference Rule) = 9 – 6 = 3 PC F 6 9

36 1. Basic Rules: Inclusion-Exclusion Rule Example 2: In a class of 50 students, 30 know Pascal, 18 know Fortran, 26 know COBOL, 9 know both Pascal and Fortran, 16 know Pascal and COBOL, 8 know both Fortran and COBOL, 47 knows at least one of the three languages. (a) how many students know none of the three languages? (b) how many students know all three languages? (c) how many students know Pascal and Fortran but not COBOL? (d) how many students know Pascal, but neither Fortran nor COBOL? P = set of students who know Pascal; C = set of students who know COBOL F = set of students who know Fortran; U = All 50 students. PC F ? (d)Similar to (c), those who know Pascal and COBOL, but not Fortran = 16 – 6 = 10. Since |P| = 30 By difference rule, those who know Pascal, but neither fortran nor COBOL = 30 – 19 = 11

37 Summary so far: Basic Counting Rules n Four basic Rules –Linear Series Rule –Multiplication Rule –Addition/Difference Rule –Inclusion-Exclusion Rule n All counting can be broken down to these four rules… they may be likened to the ‘atoms’ of counting. n IMPT: Just like the logical inference rules, you use and combine them together to create a proof, also here, you have to combine the use of the counting rules when necessary, to tackle the overall counting problem n We now use our ‘atoms’ to build common ‘procedural calls’ to tackle common counting scenarios: –Permutations –Combinations

38 n End of Lecture