Sets and Counting

6
Sets and Counting
Copyright © Cengage Learning. All rights reserved.
6.3
Decision Algorithms: The Addition and Multiplication Principles
Copyright © Cengage Learning. All rights reserved.
Decision Algorithms: The Addition and Multiplication Principles
Let’s start with a really simple example. You walk into an
ice cream parlor and find that you can choose between ice
cream, of which there are 15 flavors, and frozen yogurt, of
which there are 5 flavors.
How many different selections can you make? Clearly, you
have 15 + 5 = 20 different desserts from which to choose.
Mathematically, this is an example of the formula for the
cardinality of a disjoint union: If we let A be the set of ice
creams you can choose from, and B the set of frozen
yogurts, then A ∩ B = ∅ and we want n(A U B).
3
Decision Algorithms: The Addition and Multiplication Principles
But the formula for the cardinality of a disjoint union is
n(A U B) = n(A) + n(B), which gives 15 + 5 = 20 in this
case. This example illustrates a very useful general
principle.
Addition Principle
When choosing among r disjoint alternatives, suppose that
alternative 1 has n1 possible outcomes,
alternative 2 has n2 possible outcomes,
...
alternative r has nr possible outcomes,
with no two of these outcomes the same. Then there are a
total of n1 + n2 + · · · + nr possible outcomes.
4
Decision Algorithms: The Addition and Multiplication Principles
Quick Example
At a restaurant you can choose among 8 chicken dishes,
10 beef dishes, 4 seafood dishes, and 12 vegetarian
dishes.
This gives a total of 8 + 10 + 4 + 12 = 34 different dishes to
choose from.
Here is another simple example. In that ice cream parlor,
not only can you choose from 15 flavors of ice cream, but
you can also choose from 3 different sizes of cone. How
many different ice cream cones can you select from?
5
Decision Algorithms: The Addition and Multiplication Principles
This time, we want to choose both a flavor and a size, or, in
other words, a pair (flavor, size). Therefore, if we let A
again be the set of ice cream flavors and now let C be the
set of cone sizes, the pair we want to choose is an element
of A × C, the Cartesian product.
To find the number of choices we have, we use the formula
for the cardinality of a Cartesian product:
n(A  C) = n(A)n(C).
In this case, we get 15  3 = 45 different ice cream cones
we can select.
6
Decision Algorithms: The Addition and Multiplication Principles
This example illustrates another general principle.
Multiplication Principle
When making a sequence of choices with r steps, suppose
that
step 1 has n1 possible outcomes
step 2 has n2 possible outcomes
...
step r has nr possible outcomes
and that each sequence of choices results in a distinct
outcome. Then there are a total of n1  n2  · · ·  nr
possible outcomes.
7
Decision Algorithms: The Addition and Multiplication Principles
Quick Example
At a restaurant you can choose among 5 appetizers, 34
main dishes, and 10 desserts.
This gives a total of 5  34  10 = 1,700 different meals
(each including one appetizer, one main dish, and one
dessert) from which you can choose.
8
Example 1 – Desserts
You walk into an ice cream parlor and find that you can
choose between ice cream, of which there are 15 flavors,
and frozen yogurt, of which there are 5 flavors. In addition,
you can choose among 3 different sizes of cones for your
ice cream or 2 different sizes of cups for your yogurt. How
many different desserts can you choose from?
Solution:
It helps to think about a definite procedure for deciding
which dessert you will choose. Here is one we can use:
Alternative 1: An ice cream cone
Step 1 Choose a flavor.
Step 2 Choose a size.
9
Example 1 – Solution
cont’d
Alternative 2: A cup of frozen yogurt
Step 1 Choose a flavor.
Step 2 Choose a size
That is, we can choose between alternative 1 and
alternative 2.
If we choose alternative 1, we have a sequence of two
choices to make: flavor and size.
The same is true of alternative 2.
10
Example 1 – Solution
cont’d
We shall call a procedure in which we make a sequence of
decisions a decision algorithm.
Once we have a decision algorithm, we can use the
addition and multiplication principles to count the number of
possible outcomes.
Alternative 1: An ice cream cone
Step 1 Choose a flavor; 15 choices
Step 2 Choose a size; 3 choices
There are 15  3 = 45 possible choices in alternative 1.
Multiplication Principle
11
Example 1 – Solution
cont’d
Alternative 2: A cup of frozen yogurt
Step 1 Choose a flavor; 5 choices
Step 2 Choose a size; 2 choices
There are 5  2 = 10 possible choices in alternative 2.
Multiplication Principle
So, there are 45 + 10 = 55 possible choices of desserts.
Addition Principle
12
Decision Algorithms: The Addition and Multiplication Principles
Decision Algorithm
A decision algorithm is a procedure in which we make a
sequence of decisions.
We can use decision algorithms to determine the number
of possible items by pretending we are designing such an
item (for example, an ice-cream cone) and listing the
decisions or choices we should make at each stage of the
process.
13
Decision Algorithms: The Addition and Multiplication Principles
Quick Example
An iPod is available in two sizes. The larger size comes in
two colors and the smaller size (the Mini) comes in four
colors. A decision algorithm for “designing” an iPod is:
Alternative 1: Select Large:
Step 1 Choose a color: Two choices
(so, there are two choices for Alternative 1.)
Alternative 2: Select a Mini:
Step 1 Choose a color: Four choices
(so, there are four choices for Alternative 2.)
Thus, there are 2 + 4 = 6 possible choices of iPods.
14