Permutations and Combinations PDF
Permutations and Combinations PDF
Lecture 5
Combinatorial Analysis
• Difference Rule
• If B ⊆ A or A ⋂ B then |A - B| is |A| - |B|
A B
As a logical statement
Addition Principle or Counting
• For any two sets A and B,
|A ∪ B| = |A| + |B| – |A ∩ B|
If we shade each of A and B once, then we
shade A ∩ B twice
• Inclusion–exclusion principle
Rules of Counting
• Inclusion–exclusion principle
vars N R : Int
-- Compute permutation where order matters abc =/= bac
-- A permutation is an ordered combination.
-- perm calculates how many ways R items can be selected from N items
eq permCalc(N , R) = fact(N) quo fact(N - R) .
Beginning with row 0 and place 0, the number 20 appears in row 6, place 3. In
CafeOBJ we can check this.
red combCalc(6,3) . – gives 20
red combCalc(7,4) . – gives 35
red combCalc(7,3) . – gives 35
Special Combinations of a Set
Examples in CafeOBJ
red combCalc(5,0) . -- 1
red combCalc(2,0) . -- 1
red combCalc(5,5) . -- 1
red combCalc(5,1) . -- 5
red combCalc(5,4) . -- 5
Simplifying
Combinations of a Set
• (16.10) The number of r-combinations of n
elements is
Combination
Repetitions
size
size
Combinations with repetitions of a
Set
• Suppose 7 people each gets either a
burger, a cheese burger, or fish (3
choices). How many different orders are
possible? The answer is the number of
7-combinations with repetition of a set of 3
elements.
Rule of sum and product
• A class has 55 boys and 56 girls. What is
the total number of students in the class,
and how many different possible boy girl
pairs are there?
• Two disjoint sets, boys and girls, rule of
sum implies 55+56=111 students. The
rule of product says 55 56 = 3080.
Example
• Two bags. One bag contains a red ball
and a black ball (2). A second bag
contains a red ball, a green ball, and a
blue ball (3). A person randomly picks first
a bag and then a ball. In what fraction of
cases will a red ball be selected?
• #PossibleSelections = 2+3 = 5
• #PossibleRed = 2
• Fraction of red picked = 2/5
Permutations of a bag
• A coin is tossed 5 times, landing Head or
Tails to form an outcome. One possible
outcome is HHTTT.
• Are we choosing from a set or a bag?
• Is the permutation a set or a sequence?
• How many possible outcomes are there?
• How many outcomes have one Head?
• How many outcomes contain at most one
Head?
Permutations of a bag
How many possible outcomes are there?
Rule of product giving 25=32 possible
outcomes.
Permutations of a bag
How many outcomes have one Head?
Permutation of a bag with 1 Head and four Tails.
Permutations of a bag
• How many outcomes contain at most one
Head?
• One Head
• No Heads