CS336f1015 - Lecture 15 CS336...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 10/25/10 Lecture 15 CS336 Basic
Counting
Principles
 •  Product r ule: Suppose that a procedure can be broken down into a sequence of two tasks where there are n1 ways to do the first task and n2 ways of doing the second, then there are n1n2 ways to do the procedure. •  Sum r ule: If a task can be done either in n1 ways or n2 way then there are n1+n2 ways to do the task. Basics of Counting 2 Permutation/Combinations
 How many ways are there of arranging… Permutations (order/ no repeat) Example
 How many bit strings of length n are there? How many ways are there of selecting at once Combination (No order/no repeat) Example
 How many bit strings of length 4 contain all 1’s? Example
 How many bit strings of length 4 contain at least one 0? 1 10/25/10 Example
 How many bit strings of length 4 begin or end with a 1? Example
 How many permutations of the letters of Texas are there? Example
 How many permutations of the letters of Texas have the vowels together? Example
 How many permutations of the letters of Texas do not have the vowels together? Example 
 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 strings 
 of 
 length 
 n 
 exist 
 that 
 contain
exactly
one
a1
(allowing
repetition)?

 Example 
 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 strings 
 of 
 length 
 n 
 exist 
 that 
 contain
at
least
two
a1’s
(allowing
repetition)?

 2 10/25/10 Example 
 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 strings 
 of 
 length 
 n>0 
 exist 
 (not 
 allowing 
 repetition)?

 •  Given
the
set
of
r
symbols
{a1,
…,

ar},
how
many
 different
strings
of
length
n
exist
that
contain
exactly
 one
a1
(not
allowing
repetition)?

 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different
strings
of
length
n
exist
that
contain
at
least 
 one
a1
(not
allowing
repetition)?

 Example 
 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 selections 
 of 
 length 
 n>0 
 exist 
 (ignoring 
 order
not
allowing
repetition)?
 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 selections 
 of 
 length 
 n 
 exist 
 that 
 contain 
 at 
 least 
 one 
 a1 
 (ignoring 
 order 
 and 
 not 
 allowing 
 repetition)?

 •  Given 
 the 
 set 
 of 
 r 
 symbols 
 {a1, 
 …, 
 
 ar}, 
 how 
 many 
 different 
 selections 
 of 
 length 
 n 
 exist 
 that 
 contain 
 exactly 
 one 
 a1 
 (ignoring 
 order 
 and 
 not 
 allowing 
 repetition)?

 Example
 How
many
ways
are
there
of
arranging
6
people
 at
a
round
table?
 How
many
ways
are
there
of
arranging
six
 people
at
a
round
table
so
that
Romeo
and
 Juliet
are
sitting
next
to
one
another
but
 Ceasar
and
Brutis
are
not?
 Example
 •  How 
 many 
 ways 
 can 
 we 
 order 
 the 
 letters 
 in
 MISSISSIPPI
where
all
four
I’s
are
not
together?
 
 How
is
this
different
from
past
problems?
 Example
 
 A
bowl
contains
at
10
red
balls
and
10
blue
 balls.


 – How
many
balls
must
be
selected
in
order
to
be
 sure
there
are
at
least
three
balls
of
the
same
 color?

 – How
many
balls
must
be
selected
in
order
to
be
 sure
there
are
at
least
three
red
balls?
 Example
 How
many
ways
can
you
roll
a
pair
of
red
dice?
 3 10/25/10 Example
 How
many
ways
can
you
roll
a
pair
of
red
dice?
 Our
questions:
 order replacement yes no Table
 yes no 11 12 22 13 23 33 14 24 34 44 15 25 35 45 55 16 26 36 46 56 66 Product rule Permutation ? Combination Example
 How
many
ways
can
you
place
two
balls
in
three
 boxes?
 Example
 How
many
ways
can
you
place
two
balls
in
three
 boxes?
 1 1 1 1 1 1 2 2 2 Example
 How
many
ways
can
you
place
two
balls
in
 three
boxes?
 1 1 1 1 1 2 2 2 Example
 How
many
ways
can
you
place
two
balls
in
 three
boxes?

How
many
ways
can
we
 choose
places
for
two
balls
and
two
 transitions”

C(4,2)=6
 *|*|
 
 
 
 **||
 *||*
 
 
 
 |**|
 |*|*
 
 
 
 ||**
 *|*|
 
 
 
 **||
 *||*
 
 
 
 |**|
 1 |*|*
 
 
 
 ||**
 4 10/25/10 Table
 Our
questions:
 order replacement yes no Yes Product rule Product rule P(n,r) No Combination C(n+r-1,r) C(n,r) Example
 
 A 
 bagel 
 shop 
 has 
 onion 
 bagels, 
 poppy 
 seed
 bagels, 
 egg 
 bagels, 
 pumpernickel 
 bagels, 
 salty
 bagels, 
 sesame 
 seed 
 bagels, 
 raisin 
 bagels, 
 and
 plain
bagels.


 •  How 
 many 
 ways 
 are 
 there 
 of 
 choosing 
 six
 bagels?
 Example
 
 A
bagel
shop
has
onion
bagels,
poppy
seed
 bagels,
egg
bagels,
pumpernickel
bagels,
salty
 bagels,
sesame
seed
bagels,
raisin
bagels,
and
 plain
bagels.


 •  How
many
ways
are
there
of
choosing
a
dozen
 bagels?
 Example
 
 A
bagel
shop
has
onion
bagels,
poppy
seed
 bagels,
egg
bagels,
pumpernickel
bagels,
salty
 bagels,
sesame
seed
bagels,
raisin
bagels,
and
 plain
bagels.


 •  How
many
ways
are
there
of
choosing
a
dozen
 bagels
with
at
least
one
of
each
kind?
 Example
 
 A
bagel
shop
has
onion
bagels,
poppy
seed
 bagels,
egg
bagels,
pumpernickel
bagels,
salty
 bagels,
sesame
seed
bagels,
raisin
bagels,
and
 plain
bagels.


 •  How
many
ways
are
there
of
choosing
a
dozen
 bagels
with
at
least
3
plain?
 Example
 
 A
bagel
shop
has
onion
bagels,
poppy
seed
 bagels,
egg
bagels,
pumpernickel
bagels,
salty
 bagels,
sesame
seed
bagels,
raisin
bagels,
and
 plain
bagels.


 •  How
many
ways
are
there
of
choosing
a
dozen
 bagels
with
less
than
3
plain?
 5 10/25/10 Example
 
 A
bagel
shop
has
onion
bagels,
poppy
seed
bagels,
 egg
bagels,
pumpernickel
bagels,
salty
bagels,
 sesame
seed
bagels,
raisin
bagels,
and
plain
bagels.


 •  How
many
ways
are
there
of
choosing
a
dozen
bagels
 with
at
least
3
plain
and
no
more
than
2
onion?
 Example
 •  How
many
positive
numbers
less
than
1000
 have
at
least
one
digit
equal
9
and
the
sum
of
 the
digits
equal
13.
 6 ...
View Full Document

This note was uploaded on 11/30/2010 for the course CS 336 taught by Professor Myers during the Fall '08 term at University of Texas.

Ask a homework question - tutors are online