0% found this document useful (0 votes)
49 views4 pages

Notes 10

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

CS109A Notes for Lecture 2/12/96

Assignments With Replacements


We are given n \items," to each of which we
must assign one of k \values."
Each value may be used any number of
times from 0 up.
Let W (n; k) be the number of ways.
How many di erent ways may we assign values to the items?
\Di erent ways" means that one or more
of the items get di erent values.
Basis: W (1; k) = k (assign the one item any of k
values.
Induction: With n + 1 items, assign the rst in
k ways, and the remaining n in W (n; k) ways.
Recurrence:
W (1; k) = k
W (n + 1; k) = k W (n; k)
k is \carried along"; induction is really on n,
as if it were
T (1) = k
T (n) = k T (n 1)
Easy solution: T (n) = kn.
Example: Are there more strings of length 5 built
from three symbols or strings of length 3 built from
ve symbols?
Consider strings of length 5 whose positions
are chosen independently from symbols 0, 1,
and 2.
Values = f0; 1; 2g and \items" = the ve
positions.
Number of strings = 35 = 243.
1

Consider strings of length 3 with positions


chosen independently from symbols 0, 1, 2,
3, and 4.
Values = f0; 1; 2; 3; 4g; \items" = three
positions.
Number of strings = 53 = 125.

Permutations

Suppose we are starting a Scrabble game with a


rack of 7 di erent letters (tiles). In how many
di erent ways might we form a 7-letter word (sequence of letters, regardless of whether it is a legal
word)?
We can pick the rst letter to be any of the 7
tiles.
For each choice of rst letter, there are 6
choices of second letter, or 42 choices for the
rst 2 letters.
Similarly, for each of these 42 choices there
are 5 choices of third letter, and so on.
Total number of choices = 7 6 5
2 1 = 7!.
In general, the orders (permutations) of n
items is n!.
Inductive proof in book.

Ordered Selections

Suppose we want to begin the Scrabble game with


a 4-letter word. In how many ways might we form
the word from our 7 distinct tiles?
The rst letter is any of 7 tiles.
For each choice of rst letter there are 6
choices of second.
For each choice of 1-2, there are 5 choices of
third letter.
For each choice of 1-2-3 there are 4 choices of
fourth letter.
2

Thus, there are 7 6 5 4 = 840 words of


4 letters out of 7.
General rule: (n; m), the number of ways
to pick a sequence of m things out of n, is
n (n 1) (n 2)
(n m + 1), i.e.,
the product of m integers from n downward.
An equivalent formula: n!=(n m)!.

Combinations

Suppose we give up trying to make a word and


want to throw 4 of our 7 tiles back in the pile.
Order the 4 selected tiles in 7!=(7 4)! = 840
ways as above.
However, the same 4 tiles are selected in as
many ways as we can order 4 tiles: 4! = 24.
Thus, the number of di erent choices of 4 tiles
out of 7, ignoring the order of selection, is
7!= (7 4)!4! = 7!=(3!4!) = 35.
General rule: We can choose m items out of n,
ignoring order of selection, in n!= (n m)!m!
ways.
n
This function is usually written m and
spoken \n choose m."

A Recursive De nition for

n
m

Key idea: If we want to choose m things out of n,


we can either take or reject the rst item.
If we take the rst, we can complete the choice
by picking any m 1 of the remaining n 1.
n
We can do so in m 1 ways.
1
If we reject the rst item we must take any m
out of the remaining n 1.
Do so in nm1 ways.
n
Thus, we have an inductive de nition of m :
Basis: n = n = 1 for all n.
n
0
i.e., there is only one way to choose none or
all of n elements.
3

Induction:

n
m

n
= m 1 + nm1 for 0 < m < n.
1
The induction parameter is a little tricky:
technically it is m(n m), which is 0 for the
basis (only) and decreases in the inductive
step.

Inductive De nition = Direct De nition

n
Use c(n; m) for the inductively de ned m .
Proof is a complete induction on m(n m)
that c(n; m) = n!= (n m)!m! .
Basis: If m(n m) = 0 then m = 0 or m = n.
If m = 0, then n!= (n m)!m! = n!=n! =
1 = c(n; 0).
Note 0! = 1 is the accepted de nition.
Similarly, if m = n, n!= (n m)!m! =
n!=n! = 1 = c(n; n).
Induction: We know c(n; m) = c(n 1; m 1) +
c(n 1; m) (inductive de nition).
Since the induction parameter m(n m) is
less in both terms on the right than on the
left, we may assume
c(n 1; m 1) = (n 1)!= (n m)!(m 1)!
c(n 1; m) = (n 1)!= (n m 1)!m!
Adding the left sides: c(n; m).
Adding right sides: n!= n m)!m! .

You might also like