Permutations: A permutation is a special case of the multiplication principle. A
permutation is an arrangement. You only use permutations when order matters
or when there is an assignment. In a permutation repetitions are not allowed
(unless there is repetition in the input). (With the principle of multiplication,
repetitions may or may not be allowed.)
Fact:There are n! permutations of n (different) items.
Examples:
- How many ways can you plan your day if you have to : run an errand, study, swim,
and nap?
Answer: This question is asking about your "plan" which means that order matters. There
are 4 activities that must be scheduled and there are 4!=24 ways to schedule them.
- How many ways can you rearrange the 10 books on a shelf?
Answer:10!.
- How many "words" can you make from 7 scrabble letters?
Answer: 7!.
Some permutation questions involve ordering only some of the original items. Thea
formula for this is P(n,r) = n!/(n-r)!. Examples:
- There are 10 people in a class. How many ways can we pick 4 to sit
in 4 (different) corners of the room?
- This problem is an ordering problem since the 4 corners are different - if person
A is in the front right corner or the back left corner, we are considering those to
be different scenarios. This is a permutation problem because there are specific,
different, slots for the items (people) to go into. The answer is P(10,4) = 10!/6! =
10*9*8*7. Notice repeats not allowed.
- How many ways can you put 3 pictures on the wall out of 6 possible pictures?
Answer: Order matters so the answer is P(6,3) = 6!/3! = 6*5*4= 120.
Some problems that sound the same but are not:
- In a class of 10, how many ways can you line up the students with the 3 tallest in
front?
Answer: This is not a P(n,r) problem because the 3 special students to be in front are
already chosen (they are the tallest). Now you only have to arrange the 7 behind them
so this is a simple multiplication (or permutation of n things) problem and the answer
is 7!.
- You are taking 6 classes. You have time to work on 3 classes. How many ways
can you choose 3 classes to work on.
Answer: Here (it may be subtle) order does not matter. You are asked to "choose".
Nothing in the question asks about what order you are going to work on the classes.
So this is a combination problem and the answer is C(6,3) = 6!/3!3!.
Combinations: A combination problem is asking how many ways you can choose
a subset of some objects. Order does not matter. Usually repeats are not
allowed. If objects may not be chosen more than once, then the formula is:
Fact: The number of ways to choose r things from n things is C(n,r) = n!/r!(n-r)!.
This is called the combination of n things taken r at a time. These problems usually
contain the word "choose" or some variation.
- How many ways can you pick 5 students out of 30 to help recycle newspapers?
Answer: The students are being chosen into a group. There is no ordering and no
special slots. So the answer is C(30,5).
- You are ordering lunch for yourself and a date. There are 3 possible drinks,
5 possible sandwiches, and 4 possible dinners. How many ways can you order lunch
if you and your date cannot order the same drink, sandwich, or dinner?
Answer: We solved this problem for one person above using the multiplication principle
and the answer was 3*5*4. If you are picking 2 drinks and you can't pick the
same one twice, then there are C(3,2) ways to pick a drink, C(5,2) ways to pick
a sandwich, and C(4,2) ways to pick a dessert. The answer is: C(3,2)*C(5,2)*C(4,2).
If you were allowed to order the same things, then we would just use the multiplication
principle thinking of our slots as being:
your drink, date's drink, your sandwich, date's sandwich, your dessert, date's dessert
and the answer would be: 3*3*5*5*4*4.
 
I hope this helps.
 
Lecture notes start here:
 
Example questions :
 
Question 1: How many 5 card hands are there in a deck of 52?
 
Answer: Combination. C(52,5) =52!/47!5!
 
Question 2: How many 2 card hands are there given a deck with just 4 cards: A, 2,3,4?
 
Answer:C(4,2) = 6
 
Question 3: How many ways can you pick an Ace in a standard deck of cards?
 
Answer: 4
 
Question 4: How many ways can pick a face card(A, K, Q, J)?
 
Answer: 16 (there are 4 face cards in 4 suits)
 
Question 5: How many ways can you pick 2 face cards?
 
Answer: C(16,2) = 16!/14!2! = 16*15/2 = 8*15 = 120.
 
Question 6: How many 5 card hards contain no aces?
 
Answer: You are Choosing 5 cards from 52-4 cards since you can't chose an ace so: (48,5)
 
Question 7: How many 4 card hards contain 4 of a kind?
 
Answer: Since order doesn't matter and there are 13 different ranks, there are 13
sets of 4 cards of identical rank. So the answer is 13.
 
Question 8: How many 5 card hards contain 4 of a kind?
Answer: There are 13 different ranks (A, 2, 3, ..) you could choose for the 4 of
a kind. Then you have to pick the remaining card. There are 48 cards left. You
have to choose both the 4 of a kind AND a remaining card so you multiply. So
the answer is : 13 * 48.
 
For the next few pizza questions consider the following (8) possible toppings:
pepperoni, ham, sausage, bacon, olives, peppers, pineapple, and mushrooms.
 
Question 9: How many ways can you pick one topping for the pizza?
Answer: 8
 
Question 10: How many ways can you pick two toppings for the pizza?
Answer: C(8,2) = 8!/6!2! = 8*7/2 = 28.
 
Question 11: How many ways can you pick 3 toppings for one side of the pizza
and 2 for the other side?
Answer: C(8,3) * C(8,2)
 
Question 12: How many possible ways are there to top the pizza? This is asking
how many subsets of the 8 toppings are there?
Answer: We haven't covered this yet. Someone suggested one way of getting the
answer: C(8, 0) + C(8, 1) + C(8, 2) + ... + C(8,8). That is, the total number
of ways of topping the pizza is the number of ways to pick 0 toppings, plus the
number of ways to pick 1 topping, + ... I the number of ways to pick 8 toppings.
 
It turns out this is equal to 28. You can think of the each of the
8 possible toppings corresponding to one bit of a binary string. Then a string
like 10000000 would mean the 1st topping (pepperoni) is chosen and the rest are
not. There are 28 binary strings with 8 bits so there are 28
ways to top a pizza with 8 possible toppings.
 
This leads to an important fact:
 
Fact: C(n,0) + C(n,1) + ... + C(n,n) = 2n
 
Question 12: How many ways can you list your pizza toppings on the menu?
Answer: This is a question that involves ordering so you should think permutations.
The answer is 8!
 
Question 13: How many ways can you list your pizza toppings on the menu if the meats have to come
first?
 
Answer: There are 4 meats and 4 non-meats so there are 4! ways to order the
meats first and 4! ways to order the remaining toppings. You have to do both
the meats AND the remaining toppings so you mutliply: 4! * 4!.
 
 
Question 14: How many ways can you make a pizza that has pepperoni?
Answer: There are 2n ways to make a pizza that has n toppings. If
pepperoni is required, then we need to know how many ways there are to pick
from the other 7 toppings so the answer is: 27.
Binary Strings:
Recall: there are 2^n binary strings of length n.
 
Question: How many binary strings of length 5 have exactly 2 1's?
Answer: You can think of this in two ways. If there are exactly 2 1's then
there are 3 0's and the string is a permutation of 11000. The formula for
permutations with repeats gives an answer of: 5!/2!3!.
 
Another way to think of it: If you choose 2 places for the 1's then the 3's will
fall into place. There are C(5,2) = 5!/3!2! ways to do this.
 
Question: How many binary strings of length 5 have at least 2 1's?
Answer: We can consider cases and add them up. You can have 2, 3, 4, or 5 ones.
These cases are mutually exclusive; they do not overlap. So the answer is:
C(5,2) + C(5,3) + C(5,4) + C(5,5)
This is a combination/cases problem.
 
Question: How many binary strings of length 4 have at least 3 ones?
Answer: C(4,3) + C(4,4). This is a combination/addition (cases) problem.
 
Question: How many binary strings of length 4 have at most 3 ones?
Answer: Again you can consider the cases and add:
      C(4,0) + C(4,1) + C(4,2) + C(4,3)
This way it is a combination/addition (cases) problem.
Alternatively you can think of it this way: there are 24 binary strings
of length 4. There is only 1 string that has more than 3 ones (1111). So the
answer is 16-1 = 15.
 
Question: How many binary strings of length 4 do not contain exactly 3 1's?
Answer: 2^5 - C(5,3). To solve this problem this way, you need to think about
combinations and complements.
 
Question: How many subsets of {a,b,c,d} contain a?
Answer: 2^3 = 8. This is a subset problem.
 
Question: How many Canadian postal codes are there? A Canadian postal code has
the form: letter Number letter Number Letter Number
Answer: 26^3*10^3. This is a multiplication problem.
 
Question: How many SSN's are there? A social security number has 9 digits.
Answer: 10^9. This is a multiplication problem.
 
Question: How many SSN's start with 412?
Answer:10^6. This is a multiplication problem.
The Binominal Theorem:
 
Motivation:
The binomial theorem gives a formula for expansions of expressions like
(3x+5)7 as a sum of combinations and factors.
 
Motivation: Recall how to multiply out factors (containing 2 parts):
(a+b)^2 = (a+b)(a+b) = a^2 + 2ab + b^2
(a+b)^3 = (a+b)(a+b)(a+b) = a^3 + 3a^2b + 3ab^2 + b^3
One way to think of it is this: to multiply out (a+b)3 you "run through"
(a+b)(a+b)(a+b) choosing either the a or the b in each factor. You do this until
you have done it all possible ways. If we write our choices as 1 for a or 2 for b
and list all possible choices when there are 3 terms then we have:
Choice Term
111 aaa = a^3
112 aab = a^2 b
121 aba = a^2 b
122 abb = a b^2
211 baa = a^2 b
212 bab = a b^2
221 bba = ab^2
222 bbb = b^3
If we add the terms we get: a3 + 3a2b + 3ab2 + b3.
 
The coefficient of a2b is the number of ways we could choose 2 a's and a b.
There were 3 ways we did that: aab (a from first factor, a from 2nd factor, b from last
factor), aba, and baa. So in the final answer we see the term: 3a2b.
 
In terms of combinations, out of 3 things we wanted to choose 2 a's (and the last would
be a b). There are C(3,2) ways to choose 2 a's out of 3 possible a's (1st and 2nd factor,
1st and 3rd, 2nd and 3rd).
 
Each term in the expansion of (a+b)3 can be thought of similarly. There
are C(3,3) = 1 way to choose 3 a's from 3 factors. So the coefficient for the aaa = a3 term is 1.
 
This suggests a formula for this example:
(a+b)3 = C(3,3) a3 + C(3,2) a2b + C(3,1)ab2 + C(3,0)b3.
 
If this worked in general it would be great because it is very difficult to multiply
these things out by hand. It turns out it does work.
 
Binominal Theorem:
(a+b)n = C(n,0)a0bn-0 + C(n,1)a1bn-1 +
C(n,2)a2bn-2 + ... + C(n,n)anbn-n.
This formula works no matter what you subsitute for a and b.
 
If you substitute a = b = 1 then you get: (1+1)n (=2n) = C(n,0) + C(n,1) + ... + C(n,n). This is an important fact.
 
Sample questions:
 
Question: What is the coefficient of X^3 in (x+1)^5?
Answer: Write the expression from the binomial theorem and then look at i = 3.
(x+1)^5 = (0<=i<=5) SUM(C(5,i)x^i*1^(5-i))
So the answer is C(5,3)
 
 
Question: What is the coefficient of X^3 in (x+2)^5?
Answer: The binomial theorem gives: (x+2)^5 = (0<=i<=5) SUM(C(5,i)x^i*2^(5-i))
When i=3, C(5,3)x^3 * 2^(5-3) = 40
Pascal's Triangle:
 
Pascal's Triangle gives the binomial coefficients in an easy-to-compute way.
The top number and the numbers on the sides are all 1's. Every number inside
is the sum of the two above (to the left and right):
1 C(0,0)
1 1 C(1,0) C(1,1)
1 2 1 C(2,0) C(2,1) C(2,2)
1 3 3 1 C(3,0) C(3,1) C(3,2) C(3,4)
1 4 6 4 1 etc.
There is a combinatorial identity that makes this possible:
C(n+1, k) = C(n,k-1) + C(n,k) for 1 <= k <= n
 
C(n,0) = C(n,n) = 1 for all n >= 0.
 
Example problem involving C(n,k): Show that C(n,k) < C(n,k+1) iff k < (n-1)/2.
C(n,k) < C(n,k+1)
n!/k!(n-k)! < n!/(k+1)!(n-k-1)! divide by n! on both sides and multiply by the bottoms
(k+1)!(n-k-1)! < k!(n-k)! divide both sides by k! Note (k+1)!/k! = k+1
(k+1)(n-k-1)! < (n-k)! divide both sides by (n-k-1)!
k+1 < n-k
2k < n-1
k < (n-1)/2 QED