CS 70
Discrete Mathematics for CS
Spring 2008
David Wagner
Note 14
Counting
In the next major topic of the course, we will be looking at probability. Suppose you toss a fair coin a
thousand times. How likely is it that you get exactly 500 heads? And what about 1000 heads? It turns out
that the chances of 500 heads are roughly 5%, whereas the chances of 1000 heads are so infinitesimally
small that we may as well say that it is impossible. But before you can learn to compute or estimate odds or
probabilities you must learn to count! That is the subject of this note.
We will learn how to count the number of outcomes while tossing coins, rolling dice and dealing cards.
Many of the questions we will be interested in can be cast in the following simple framework called the
occupancy model:
Balls in Bins:
We have a set of
k
balls. We wish to place them into
n
bins. How many different possible
outcomes are there?
How do we represent coin tossing and card dealing in this framework? Consider the case of
n
=
2 bins
labelled
H
and
T
, corresponding to the two outcomes of a coin toss. The placement of the
k
balls correspond
to the outcomes of
k
successive coin tosses. To model card dealing, consider the situation with 52 bins
corresponding to a deck of cards. Here the balls correspond to successive cards in a deal.
The two examples illustrate two different constraints on ball placements. In the coin tossing case, different
balls can be placed in the same bin. This is called
sampling with replacement
. In the cards case, no bin
can contain more than one ball (i.e., the same card cannot be dealt twice). This is called
sampling without
replacement
. As an exercise, what are
n
and
k
for rolling dice? Is it sampling with or without replacement?
We are interested in counting the number of ways of placing
k
balls in
n
bins in each of these scenarios. This
is easy to do by applying the first rule of counting:
First Rule of Counting:
If an object can be made by a succession of choices, where there are
n
1
ways of
making the first choice, and
for every
way of making the first choice there are
n
2
ways of making the second
choice, and
for every
way of making the first and second choice there are
n
3
ways of making the third choice,
and so on up to the
n
k
th choice, then the total number of distinct objects that can be made in this way is the
product
n
1
·
n
2
·
n
3
···
n
k
.
Here is another way of picturing this rule: consider a tree with branching factor
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 PAPADIMITROU
 Natural number, Card game

Click to edit the document details