Download Discrete Structures Lecture 24: Counting I and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!
11/5/
CSci 243
Discrete Structures
Lecture 24Counting I:Introduction
11/5/
Outline^ • Motivation• Sum, Product, Division Rules• The Inclusion-Exclusion Principle• Venn Diagrams, Tree Diagrams• The Pigeonhole Principle
11/5/
The Sum Rule^ •
The Sum Rule: If there are
n ways of doing one
task, and
m ways of doing another, and the two
tasks are independent, then there are
n+m
ways to do
either task.
- QC: [Pretend] you can drop either a test (2),
quiz (10), or project grade (4). How manypossibilities?
11/5/
The Product Rule^ •
The Product Rule: If there are
n ways of doing
one task, and
m ways of doing another, and you
do the second task after the first, then there aren·m ways to do
both tasks.
- QC: How many double-scoop ice cream cones
are there if there are 32 flavors (order matters)?
- What if order didn’t matter?
11/5/
When To Use Which?^ • How many passwords of 8 alphanumeric chars?• Need a student representative for a committee.
There are 100 grads and 300 ugrads. How manypossibilities?
- How many functions from set A to set B?• How many 3-digit numbers are divisible by 2?• How many W&M userids can there be?
11/5/
Next up… Inclusion/Exclusion
11/5/
- Set #1: 3-digit numbers which begin with 1 -^
|{100, 101, 102, …, 197, 198, 199}| =?
- Set #2: 3-digit numbers which end with 0 -^
|{100, 110, 120, …, 970, 980, 990}| =?
- We double-counted the ones in both sets:
3-digit numbers which begin with 1, end with 0•
|{100, 110, 120, …, 170, 180, 190}| =?
- So just subtract out the ones in both sets: -^
?
Inclusion/Exclusion Princ.: Concept
11/5/
The Inclusion/Exclusion Principle^ •
The Inclusion/Exclusion Principle: Suppose thereare two tasks for which some ways of doingthem can be done at the same time.The number of ways of doing two tasks is:•
the number of ways for the first task
-^
plus the number of ways for the second task
-^
minus the number of ways of doing both tasks
- But “tasks” is confusing… Let’s use sets instead
11/5/
Quick Question^ • How many bit strings of length 8 either start
with a 1 or end with 00?•
Use product rule and inclusion/exclusion
11/5/
Generalizing Inclusion/Exclusion^ • Want to compute: |A
U
B
U
C|
• |A
U
B
U
C| =?
11/5/
Tree Diagram Example^ • How many ways to get 2 heads out of three coin
tosses?
11/5/
Quick Question^ • How many ways to get no more than two heads
in a row, out of 4 coin tosses?(No 3-in-a-row, or 4-in-a-row)
11/5/
The Pigeonhole Principle: Concept^ • If you put 6 pigeons in 4 coop pigeonholes, then
at least one pigeonhole has 2 or more pigeons init.
- QC: How could a pigeonhole have
more than 2?
- QC: What is the minimum number to guarantee
that a pigeonhole has 2 or more pigeons?
11/5/
The Pigeonhole Principle^ •
The Pigeonhole Principle: If
k+1 or more objects
are places into
k boxes, then there is at least
one box containing two or more objects.
- QC: If we have a set of 27 English words, what
do we know?
- QC: There were 22 distinct grades for the last
test. What do we know? (27 tests taken)