Professional Documents
Culture Documents
Counting and ProbabilityMTH1114 April 2023
Counting and ProbabilityMTH1114 April 2023
UNIT 1
FUNDAMENTAL PRINCIPLES OF COUNTING
Zaharin Yusoff (Prof Dr)
SCHOOL
◆ UNIT 1 – Fundamental Principles of Counting
Rule of Sum
Rule of Product Chapter 1:
Permutation 1.1 → 1.4
Combination pg 3 → 36
― Binomial Theorem
― Combinations with repetition
What is available
How many positions How many positions
of interest not interested in
P( n, r )
What is available
– This chapter is still on mathematics, for counting possibilities … but it will be applied to computing
– In any case, we are still essentially dealing with numbers, and thus the basic computing operations
(arithmetic) are adequate (which are readily available in any computer language)
– In fact, these are single numbers, and thus not even ordering is required → a point (0-dimensional),
as compared to a line (with order, 1-dimensional), and matrices (2-dimensional), etc. (see later Units)
– The computer representation for numbers is essentially a single variable (with Type, Length, etc.)
The Rule of Sum: If a first task can be performed in m ways, while a second task
can be performed in n ways, and the two tasks cannot be performed simultaneously
(i.e. they are independent of each other, or disjoint)
then performing either (1) task can be accomplished in any one of m + n ways
The rule applies to more than two tasks as long as no pairs of the tasks
can occur simultaneously
The Rule of Product (or Principle of Choice): If a procedure can be broken down into
first and second stages, and if, for each of these outcomes (2 tasks are performed),
− there are m possible outcomes for the first stage and if, for each of these outcomes
− there are n possible outcomes for the second stage,
then the total procedure can be carried out, in the designated order, in m x n ways
If 6 men and 8 women came for the audition, how many ways can we select a
hero and a heroine? 6 × 8 = 48 ways
Example If the drama club is looking to select a star and then a co-star
irrespective of male or female
If 14 people came for the audition, then there will be 14 × 13 = 182 ways
(because once the star is chosen, s/he cannot be the co-star)
Example A typical PIN (Personal Identification Number) is a sequence of any
four symbols chosen from the 26 letters in the alphabet and the ten
digits (including 0). How many different PINS are possible?
a) With repetitions of letters and digits allowed.
36 x 36 x 36 x 36 = 364
b) If no letter or digit can be repeated
36 x 35 x 34 x 33
A boss sends her assistant to the cafe to get her lunch, either a muffin and a hot
beverage, or a sandwich and a cold beverage.
Possibilities:
A muffin and a hot beverage: 6 x 2 = 12 ways
A sandwich and a cold beverage: 8 x 3 = 24 ways
There are four disjoint cases (not counting the case of no password at all)
− If three digits, there are 26 x 26 x 26 = 263
− If 2 digits, there are 26 x 26 = 262
− If 1 digit, there are 26 = 261
→ 263 + 262 + 261 different passwords possible (from rule of sum)
Example In how many ways can we select two books from different subjects
among five distinct computer science (CS) books, three distinct
mathematics (M) books, and two distinct art (A) books?
There are 3 possible pairs of books, these being disjoint cases (and for each, we use
the rule of product):
− We can select two books, one from CS & one from M: 5 x 3 = 15 ways.
− Similarly we can select two books, one from CS & one from A: 5 x 2 = 10 ways
− We can also select two books from M & one from A: 3 x 2 = 6 ways.
n × (n - 1) × (n - 2) × … × (n – r + 1)
1st 2nd 3rd rth
position position position position
Note
P(n, r) counts (linear) arrangements in which the objects cannot be repeated.
However, if repetitions are allowed, then by the rule of product there are nr
possible arrangements with r ≥ 0
Example The word COMPUTER has 8 letters, none repeated.
a) The number of permutations of the letters in the word COMPUTER is 8!
a) If only 3 of the letters are used, the number of permutations (of size 3) is
Example Unlike in the above, the number of (linear) arrangements of the four
letters in BALL is 12 (i.e. not 4! = 24).
This is because the L is repeated, and there are 2! ways to do this.
As such, we have to divide the total number of ways by this amount:
4! . = 24. = 12
2! 2
Example The word PEPPER has 6 letters, with P repeated 3 times, and E twice
There are 3! ways for repeats of P, and 2! for repeats of E.
As such, we have to divide the total number of ways by these amounts:
6! . = 6.5.4 = 60
(3! 2!) 2
Example The MASSASAUGA is a brown and white venomous snake indigenous
to North America.
The word has 10 letters, with 4 A’s, 3 S’s, and M, U, G.
❑ For the same reason if all 4 A’s are to be arranged together, and the 3 S’s
are to be arranged together as well, we have 5! = 120 permutations
1.3 Combinations: The Binomial Theorem
(pg. 14 → 26)
Combinations
Now, if there is no reference to order, in the sense that we are not concerned about
the order of the r elements chosen, we need to take into account the r! ways of
arranging the r chosen objects (just like the number of repeats) – hence to divide
the permutations by r!. This kind of selection is called a combination.
Important note: When dealing with any counting problem, we should ask ourselves
about the importance of order in the problem. When order is relevant, we think in
terms of permutations and arrangements and the rule of product. When order is not
relevant, combinations could play a key role in solving the problem.
Example A hostess is having a dinner party for some members of her charity
committee. Because of the size of her home, she can invite only 11 of
the 20 committee members.
There are 9 possible locations for the 3 A’s in between the other 8 letters
Just an example ….
Notice that it is also possible to express the result of the theorem as:
Example From the binomial theorem it follows that the coefficient of x5y2 in
the expansion of (x + y)7 is:
7C = 7C2 = 7! . = 7.6 = 21
5
(5! 2!) 2
PROBABILITY
• MTH1114
• ComputerMaths
•Solution:
•E2: “integer is divisible by 2”
E5: “integer is divisible by 5”
•E2 = {2, 4, 6, …, 100}
•|E2| = 50
•p(E2) = 0.5
47
The Pigeonhole Principle
•The generalized pigeonhole principle: If N objects are
placed into k boxes, then there is at least one box containing
at least N/k of the objects.
•Example 1: In a 60-student class, at least 12 students will
get the same letter grade (A, B, C, D, or F).
•Example 2: In a 61-student class, at least 13 students will
get the same letter grade.
48
The Pigeonhole Principle
•Example 3: Assume you have a drawer containing a
random distribution of a dozen brown socks and a dozen
black socks. It is dark, so how many socks do you have to
pick to be sure that among them there is a matching pair?
49
Computer Representation