1 Basics of Counting CS/APMA 202 Rosen section 4.1 Aaron Bloomfield.

Slides:



Advertisements
Similar presentations
1 Basics of Counting CS/APMA 202 Epp sections 6.2 & 6.3 Aaron Bloomfield.
Advertisements

Binomial Coefficients
Probability Three basic types of probability: Probability as counting
Recursively Defined Functions
Section 4.1: The Basics of Counting As we have seen, one way to count the number of objects in a finite set S is to produce a one-to-one correspondence.
Advanced Counting Techniques Prof. Johnnie Baker
Chapter 7 Logic, Sets, and Counting
College of Information Technology & Design
1 Discrete Math CS 2800 Prof. Bart Selman Module Counting Chapter 5, Rosen.
Chapter 7 Logic, Sets, and Counting Section 3 Basic Counting Principles.
Copyright © Zeph Grunschlag, Counting Techniques Zeph Grunschlag.
1 Discrete Math CS 280 Prof. Bart Selman Module Probability --- Part a) Introduction.
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;
1 Section 5.1 Discrete Probability. 2 LaPlace’s definition of probability Number of successful outcomes divided by the number of possible outcomes This.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
The Basics of Counting: Selected Exercises. Copyright © Peter Cappello2 Sum Rule Example There are 3 sizes of pink shirts & 7 sizes of blue shirts. How.
1 Set Operations CS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield.
1 The Pigeonhole Principle CS/APMA 202 Rosen section 4.2 Aaron Bloomfield.
1 Integers and Division CS/APMA 202 Rosen section 2.4 Aaron Bloomfield.
1 Permutations and Combinations CS/APMA 202 Epp section 6.4 Aaron Bloomfield.
Permutations and Combinations
Chapter 5 Section 5 Counting Techniques.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications (5 th edition) Kenneth H. Rosen Chapter 4 Counting.
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.
Recursive Definitions and Structural Induction
1 Sequences and Summations CS/APMA 202 Rosen section 3.2 Aaron Bloomfield.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
1 Partial Orderings Aaron Bloomfield CS 202 Rosen, section 7.6.
Discrete Maths Objective to introduce some of the counting rules (product, sum, subtraction, division, pigeonhole) through examples , Semester 2,
1 Permutations and Combinations CS/APMA 202 Rosen section 4.3 Aaron Bloomfield.
Number of Elements in a Finite Set. Notation : The number of the elements of the set A will be denoted by n(A) Examples (1): Let: Let: A = {a,b,c,d} B.
1 Predicates and Quantifiers CS/APMA 202, Spring 2005 Rosen, section 1.3 Aaron Bloomfield.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Counting Subsets of a Set: Combinations Lecture 31 Section 6.4 Wed, Mar 21, 2007.
2 Permutations and Combinations Lesson 8 HAND OUT REFERENCE SHEET AND GO OVER IT.
1 Proof Strategies CS/APMA 202 Rosen section 3.1 Aaron Bloomfield.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
1 Binomial Coefficients CS 202 Epp, section ??? Aaron Bloomfield.
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.
1 Relations and Their Properties Rosen, section 7.1 CS/APMA 202 Aaron Bloomfield.
Rosen, Section 8.5 Equivalence Relations
1 Algorithms CS/APMA 202 Rosen section 2.1 Aaron Bloomfield.
Representing Relations
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
Counting Techniques. L172 Agenda Section 4.1: Counting Basics Sum Rule Product Rule Inclusion-Exclusion.
ICS 253: Discrete Structures I Discrete Probability King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 16
Discrete Structures Counting (Ch. 6)
1 Introduction to Discrete Probability Rosen, section 5.1 CS/APMA 202 Aaron Bloomfield.
Introduction to Discrete Probability Epp, section 6.x CS 202.
1 Applications of Number Theory CS/APMA 202 Rosen section 2.6 Aaron Bloomfield.
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
CS/APMA 202 Spring 2005 Aaron Bloomfield. Sequences in Nature
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.
Permutations and Combinations
Aaron Bloomfield CS 202 Rosen, section 7.4
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
Proof methods We will discuss ten proof methods: Direct proofs
Permutations and Combinations
Permutations and Combinations
Recursively Defined Functions
CS100: Discrete structures
Discrete Structures for Computer Science
Copyright © Zeph Grunschlag,
Copyright © Zeph Grunschlag,
Presentation transcript:

1 Basics of Counting CS/APMA 202 Rosen section 4.1 Aaron Bloomfield

2 The product rule If there are n 1 ways to do task 1, and n 2 ways to do task 2 Then there are n 1 n 2 ways to do both tasks in sequence Then there are n 1 n 2 ways to do both tasks in sequence This applies when doing the “procedure” is made up of separate tasks This applies when doing the “procedure” is made up of separate tasks We must make one choice AND a second choice We must make one choice AND a second choice

3 Product rule example Rosen, section 4.1, question 1 (a) There are 18 math majors and 325 CS majors There are 18 math majors and 325 CS majors How many ways are there to pick one math major and one CS major? How many ways are there to pick one math major and one CS major? Total is 18 * 325 = 5850

4 Product rule example Rosen, section 4.1, question 22 (a) and (b) How many strings of 4 decimal digits… a)Do not contain the same digit twice? We want to chose a digit, then another that is not the same, then another… First digit: 10 possibilities Second digit: 9 possibilities (all but first digit) Third digit: 8 possibilities Fourth digit: 7 possibilities Total = 10*9*8*7 = 5040 b)End with an even digit? First three digits have 10 possibilities Last digit has 5 possibilities Total = 10*10*10*5 = 5000

5 The sum rule If there are n 1 ways to do task 1, and n 2 ways to do task 2 If these tasks can be done at the same time, then… If these tasks can be done at the same time, then… Then there are n 1 +n 2 ways to do one of the two tasks Then there are n 1 +n 2 ways to do one of the two tasks We must make one choice OR a second choice We must make one choice OR a second choice

6 Sum rule example Rosen, section 4.1, question 1 (b) There are 18 math majors and 325 CS majors There are 18 math majors and 325 CS majors How many ways are there to pick one math major or one CS major? How many ways are there to pick one math major or one CS major? Total is = 343

7 Sum rule example Rosen, section 4.1, question 22 (c) How many strings of 4 decimal digits… c)Have exactly three digits that are 9s? The string can have: The string can have: The non-9 as the first digit OR the non-9 as the second digit OR the non-9 as the third digit OR the non-9 as the fourth digit Thus, we use the sum rule For each of those cases, there are 9 possibilities for the non-9 digit (any number other than 9) For each of those cases, there are 9 possibilities for the non-9 digit (any number other than 9) Thus, the answer is = 36 Thus, the answer is = 36

8 Quick survey I’m feeling good with the sum rule and the product rule… I’m feeling good with the sum rule and the product rule… a) Very well b) With some review, I’ll be good c) Not really d) Not at all

9 More complex counting problems We combining the product rule and the sum rule Thus we can solve more interesting and complex problems

10 Wedding pictures example Rosen, section 4.1, question 38 Consider a wedding picture of 6 people There are 10 people, including the bride and groom There are 10 people, including the bride and groom a)How many possibilities are there if the bride must be in the picture Product rule: place the bride AND then place the rest of the party First place the bride She can be in one of 6 positions Next, place the other five people via the product rule There are 9 people to choose for the second person, 8 for the third, etc. Total = 9*8*7*6*5 = Product rule yields 6 * = 90,720 possibilities

11 Wedding pictures example Rosen, section 4.1, question 38 Consider a wedding picture of 6 people There are 10 people, including the bride and groom There are 10 people, including the bride and groom b)How many possibilities are there if the bride and groom must both be in the picture Product rule: place the bride/groom AND then place the rest of the party First place the bride and groom She can be in one of 6 positions He can be in one 5 remaining positions Total of 30 possibilities Next, place the other four people via the product rule There are 8 people to choose for the third person, 7 for the fourth, etc. Total = 8*7*6*5 = 1680 Product rule yields 30 * 1680 = 50,400 possibilities

12 Wedding pictures example Rosen, section 4.1, question 38 Consider a wedding picture of 6 people There are 10 people, including the bride and groom There are 10 people, including the bride and groom c)How many possibilities are there if only one of the bride and groom are in the picture Sum rule: place only the bride Product rule: place the bride AND then place the rest of the party First place the bride She can be in one of 6 positions She can be in one of 6 positions Next, place the other five people via the product rule There are 8 people to choose for the second person, 7 for the third, etc. We can’t choose the groom! Total = 8*7*6*5*4 = 6720 Product rule yields 6 * 6720 = 40,320 possibilities OR place only the groom OR place only the groom Same possibilities as for bride: 40,320 Sum rule yields 40, ,320 = 80,640 possibilities

13 Wedding pictures example Rosen, section 4.1, question 38 Consider a wedding picture of 6 people There are 10 people, including the bride and groom There are 10 people, including the bride and groom Alternative means to get the answer c)How many possibilities are there if only one of the bride and groom are in the picture Total ways to place the bride (with or without groom): 90,720 From part (a) Total ways for both the bride and groom: 50,400 From part (b) Total ways to place ONLY the bride: 90,720 – 50,400 = 40,320 Same number for the groom Total = 40, ,320 = 80,640

14 Quick survey I’m feeling good with these sum and product rule examples… I’m feeling good with these sum and product rule examples… a) Very well b) With some review, I’ll be good c) Not really d) Not at all

15 End of lecture on 29 March 2005

16 The inclusion-exclusion principle When counting the possibilities, we can’t include a given outcome more than once! |A 1  U A 2 | = |A 1 | + |A 2 | - |A 1  ∩ A 2 | Let A 1 have 5 elements, A 2 have 3 elements, and 1 element be both in A 1 and A 2 Let A 1 have 5 elements, A 2 have 3 elements, and 1 element be both in A 1 and A 2 Total in the union is = 7, not 8 Total in the union is = 7, not 8

17 Inclusion-exclusion example Rosen, section 4.1, example 16 How may bit strings of length eight start with 1 or end with 00? Count bit strings that start with 1 Rest of bits can be anything: 2 7 = 128 Rest of bits can be anything: 2 7 = 128 This is |A 1 | This is |A 1 | Count bit strings that end with 00 Rest of bits can be anything: 2 6 = 64 Rest of bits can be anything: 2 6 = 64 This is |A 2 | This is |A 2 | Count bit strings that both start with 1 and end with 00 Rest of the bits can be anything: 2 5 = 32 Rest of the bits can be anything: 2 5 = 32 This is This is |A 1  ∩ A 2 | This is This is |A 1  ∩ A 2 | Use formula |A 1  U A 2 | = |A 1 | + |A 2 | - |A 1  ∩ A 2 | Total is – 32 = 160

18 Bit string possibilities Rosen, section 4.1, question 42 How many bit strings of length 10 contain either 5 consecutive 0s or 5 consecutive 1s?

19 Bit string possibilities Consider 5 consecutive 0s first Sum rule: the 5 consecutive 0’s can start at position 1, 2, 3, 4, 5, or 6 Starting at position 1 Starting at position 1 Remaining 5 bits can be anything: 2 5 = 32 Starting at position 2 Starting at position 2 First bit must be a 1 Otherwise, we are including possibilities from the previous case! Otherwise, we are including possibilities from the previous case! Remaining bits can be anything: 2 4 = 16 Starting at position 3 Starting at position 3 Second bit must be a 1 (same reason as above) First bit and last 3 bits can be anything: 2 4 = 16 Starting at positions 4 and 5 and 6 Starting at positions 4 and 5 and 6 Same as starting at positions 2 or 3: 16 each Total = = 112 Total = = 112 The 5 consecutive 1’s follow the same pattern, and have 112 possibilities There are two cases counted twice (that we thus need to exclude): and Total = – 2 = 222

20 Tree diagrams We can use tree diagrams to enumerate the possible choices Once the tree is laid out, the result is the number of (valid) leaves

21 Tree diagrams example Rosen, section 4.1, question 48 Use a tree diagram to find the number of bit strings of length four with no three consecutive 0s

22 An example closer to home… win lose win lose win lose How many ways can the Cavs finish the season 9 and 2? Playing Miami Playing GA Tech Playing VA Tech (7,1) (7,2)(8,1) (7,3) (7,4)(8,3)(7,3) (8,2) (9,2) (8,2)(9,1) (8,3)(9,2) (10,1)

23 Quick survey I felt I understood the material in this slide set… I felt I understood the material in this slide set… a) Very well b) With some review, I’ll be good c) Not really d) Not at all

24 Quick survey The pace of the lecture for this slide set was… The pace of the lecture for this slide set was… a) Fast b) About right c) A little slow d) Too slow

25 Quick survey How interesting was the material in this slide set? Be honest! How interesting was the material in this slide set? Be honest! a) Wow! That was SOOOOOO cool! b) Somewhat interesting c) Rather borting d) Zzzzzzzzzzz

26 Beware!!!