Week 13
Week 13
Example 1 Example 2
How many distinct 4-digit pins can be set? A new company with just two employees, Ahmed and Bilal, rents a floor of a building
with 12 offices. How many ways are there to assign different offices to these two
employees?
Example 3 – 5 Example 6 – 7
3. The chairs of an auditorium are to be labelled with an upper-case English letter 6. How many different car’s number-plates can be made if each plate contains a
followed by a positive integer not exceeding 100. What is the largest number of chairs sequence of three uppercase English letters followed by three digits (and no sequences
that can be labelled differently? of letters are prohibited, even if they are obscene)?
Solution: The procedure labelling a chair consists of assigning an English letter in 26 Answer: 26 · 26 · 26 · 10 · 10 · 10 = 17, 576, 000 possible number-plates.
ways and the task of assigning a number in 100 ways. 7. How many functions are there from a set with 𝑚 elements to a set with 𝑛 elements?
So the entire procedure can be done in 26 · 100 = 2600 ways. Solution: Note that each element of the codomain can be chosen in n ways and
4. There are 32 microcomputers in a computer centre. Each microcomputer has 24 ports. there are m elements in the domain.
How many different ports to a microcomputer in the centre are there? Hence, by the product rule there are 𝑛 · 𝑛 ⋯ 𝑛 = 𝑛
Answer: 32 · 24 = 768. functions from a set with m elements to one with n elements.
5. How many different bit strings of length eight are there? For example, there are 5 = 125 different functions from a set with three elements to a
Answer: 2 = 256. set with five elements.
Example 8 Example 9
How many one-to-one functions are there from a set with m elements to one with n
elements? What is the value of 𝑘 after the following code, where 𝑛 , 𝑛 , . . . , 𝑛 are positive
integers, has been executed?
Solution: First note that when 𝑚 > 𝑛 there are no one-to-one functions from a set with m
elements to a set with n elements.
When 𝑚 ≤ 𝑛, let the elements in the domain are 𝑎 , 𝑎 , … , 𝑎 .
There are 𝑛 ways to assign a value at 𝑎 .
Because the function is one-to-one, the value of the function at 𝑎 can be picked in 𝑛 − 1
ways (as the value assigned to a1 cannot be assigned again).
In general, the value of the function at 𝑎 can be chosen in 𝑛 − 𝑘 + 1 ways.
By the product rule, there are
𝑛(𝑛 − 1)(𝑛 − 2) · · · (𝑛 − 𝑚 + 1)
one-to-one functions from a set with m elements to one with n elements.
For example, there are 5 · 4 · 3 = 60 one-to-one functions from a set with three elements
to a set with five elements.
DS - Induction, Recursion, and Counting 21 DS - Induction, Recursion, and Counting 22
1/1/2025
Examples Examples
Among a group of 367 people (randomly chosen), there must be at least two with the
same birthday, because there are only 366 possible birthdays. How many students must be in a class to guarantee that at least two students receive
In any group of 27 English words (randomly chosen), there must be at least two that the same score on the final exam, if the exam is graded on a scale from 0 to 100
begin with the same letter, because there are 26 letters in the English alphabet. points?
Among a set of 8 or more students, at least 2 are born on the same day of the week. Ans. 102. (CW)
(Why?) Show that if there are 30 students in a class, then at least two have last names that
In a club with 400 members, must there be some pair of members who share the same begin with the same letter. (Q2 Ex. 6.2)
birthday. Why? Let 𝑑 be a positive integer. Show that among any group of 𝑑 + 1 (not necessarily
Baber has a drawer full of 12 red and 14 green socks. In order to avoid waking his consecutive) integers there are two with exactly the same remainder when they are
roommate, he must grab a selection of clothes in the dark and get dressed out in the divided by 𝑑. (Q6 Ex. 6.2)
hallway. How many socks must he grab to be assured of having a matching pair? Show that if five integers are selected from the first eight positive integers, there
Solution: Let 𝑓 ∶ 𝑋 → 𝐶 be the function that assigns a colour to each sock, where must be a pair of these integers with a sum equal to 9. (Q13 Ex. 6.2)
𝐶 = {red, green } and 𝑋 = be the set of socks Baber selects. By pigeonhole principle, 𝑋 > 𝐶 = 2.
Three is enough.
DS - Induction, Recursion, and Counting 31 DS - Induction, Recursion, and Counting 32
1/1/2025
Homework
Exercise 6.2
Q1 to Q6 + Q13, Q15, Q17, Q19.