Suppose a task 1 can be done n ways and a task 2 can be done in m ways.
Assume that both tasks are independent, that is, performing task 1 doesn't mean performing task 2 and vice versa.
In this case, the number of ways of executing task 1 or task 2 is equal to n + m.
Example
The computing department must choose either a student or a member of academic staff as a representative for university committee.
How many ways of choose this representative are there if there are 10 academic staff and 77 math students, and no one is both a member of academic staff and a student?
Solution
By the addition rule, there are 10 + 77 ways of choosing this representative.
The sum rule in terms of sets
Let A be the set of ways to do task 1 and B the set of ways to do task 2, where A and B are disjoint sets.
The sum rule can be phrased in terms of sets:
∣A∪B∣=∣A∣+∣B∣ as long as A and B are disjoint sets.
Combining the sum and product rules
We can combine the sum and product rules to solve more complex problems.
Example:
Suppose a letter in a programming language can be either a single letter or a letter followed by 2 digits.
What is the number of possible labels?
Solution:
The number of labels with one letter only is 26
Using the product rule the number of labels with a letter folowed by 2 digits is 26 x 10 x10
Using the sum rule the total number of labels is 26 + 26>10.10 = 2,626.
Suppose a tak can be done using a procedure that can be carried out in n ways, for every way w, exactly d of the n ways correspond to w.
Then this task can be done n/d ways
In terms of sets: if the finite set A is the union of n pair-wise disjoint subsets each with d elements, the n=∣A∣/d
In terms of functions: if f is a function from A to B, where both are finite sts, and for every value y \in B there are exactly d values x \in A such that f(x)=y, then ∣B∣=∣A∣/d
Example:
In how many ways can we seat 4 people around a table, where 2 seating arrangements are considered the same when each person has the same left and right neighbour
Solution:
Let's first number the seats around the table from 1 to 4 proceeeding clockwise:
There are 4 ways to select the person for seat 1, three for seat 2, two for seat 3 and one for seat 4
Thus there are 4.3.2.1=24 ways to order the four people.
Since 2 seating arrangments are the same when each person has the same left and right neighbour, for every choice for seat 1, we get the same seating.
Therefore, by using the division rule, there are 24/4=6 different seating arrangements.
Lesson 10.105 The pigeonhole principal
Pigeonhole principal
One of simplest and most useful ideas in maths
Let K be a positive integer:
If k is a positive integer and k+1 objects are placed into k boxes, then at least one box contains 2 or more objects.
Proof by contrapositive:
Suppose none of the k boxes has more than 1 object.
The total number of objects would be at most k.
Which contradicts the statement that we have k+1 objects.
Example:
If a flock of 10 pigeons roosts in a set of 9 pigeonholes, 1 of the pigeon holes must have more than 1 pigeon.
Exercise
Prove that a function f from a set with k + 1 elements to a set with k elements is not a one-to-one.
Solution: We can prove this using the peigonhole principle:
Create a boxy, for each element y in the co-domain of f
Put all elements x from the domain in the box for y such that f(x) = y
Because there are k + 1 elements and only k boxes, at least one box has two or more elements.
Therefore, f is not one-to-one.
The generalised pigeonhole principle
If N objects are placed into k boxes, then there is at least one box containing at least ceil(N/k) objects, where ceil(x) is called the ceiling function, which represents the round-up value of x
Let's prove it by contrapositive:
Suppose none of the boxes contains more than ⌈N/k⌉−1 objects.
Then the total number of objects is at most: k(⌈kN⌉−1)<k((kN+1)−1)=N
This is a contradiction because there is a total of N objects.
Example:
How many cards must be selected from a standard deck of 52 cards to guarantee that at least four cards of the same suit are chosen?
Solution:
Assume 4 boxes, one for each suit.
Using the generalised pigeonhole principle, at least one box contains at least ⌈4N⌉, where N is the number of cards selected.
At least 4 cards of one suit are selected if ⌈4N⌉≥4
The smallest integer N such that ⌈4N⌉≥4 is equal to 13.
Video: 10.107 Permutations and combinations
Many counting problems can be solved by finding the number of ways to arrange a specified number of distinct elements of a set of particular size, where the order of this element matters, and in some cases doesn't.
This lecture discusses permutations and combinations, which are used to solve this counting problem.
A permutation of a set of distinct objects is an ordered arrangement of these objects.
An ordered arrangement of r elements of a set is called an r-permutation.
The number of r-permutations of a set with n elements is denoted by P(n,r)
Example:
Let S={1,2,3}
The ordered arrangement 3,1,2 is a 3-permutation of S.
The ordered arrangement 3,2 is a 2-permutation of S
The 2-permutations of S = {1, 2, 3} are 1,2; 1,3; 2,1; 2,3; 3,1 and 3,2
Hence, P(3,2) = 6
Number of permutations
If n is a positive integer and r is an integer with r≤n, then there are P(n,r)=n(n−1)(n−2)...(n−(r−1)) r-permutations of a set with n distinct elements.
We can formulate this as:
P(n,r)=(n−r)!n!
Proof:
By product rule:
there are n different ways for choosing the 1st element.
n-1 ways for choosing the 2nd element.
n -3 ways for choosing the 3rd element, etc.
there are (n−(r−1)) ways to choose the last element.
hence, P(n,r)=n(n−1)(n−2)...(n−(r−1))
P(n,0)=1, since there is only one way to order zero.
Example
How many possible ways are there of selecting a first prize winner, a 2nd price winner and third-prize winner from 50 different people?