CS6015: Linear Algebra and Random Processes
Lecture 25: Counting collections
Learning Objectives
What are collections and how do you count them?
Collections
Recap
In a sequence order matters
cat act
even though both words have the same letters: {t, c, a}
\neq
Collections
In a collection order does not matter
cat = cta = act = atc = tac = tca
all the 6 words have the same letters: {t, c, a}
\frac{n!}{(n-k)!}
a b c d e f g h i j k l m n o p q r s t u v w x y z
n = 26
k = 3
How many sequences of 3 letters can you form (no repetition)?
How many collections of 3 letters can you form (no repetition)?
We don't know!
But we know how to count sequences! Can we reuse that knowledge?
Sequences: Breaking it down
a b c d e f g h i j k l m n o p q r s t u v w x y z
26
3
Step 1: select the 3 letters to be put in the word
Step 2: re-arrange the 3 letters in 3! ways
a b c d e f g h i j k l m n o p q r s t u v w x y z
n
k
Step 1: select the k items to be put in the sequence
Step 2: re-arrange the k items in k! ways
Sequences: Breaking it down
Making a collection
Re-arranging elements in the collection
N = number of ways of selecting k elements
k! = number of ways of re-arranging the k terms
Sequences: Breaking it down
Making a collection
Re-arranging elements in the collection
Number of sequences
= N * k!
= \frac{n!}{(n-k)!}
\therefore N = \frac{n!}{(n-k)!k!}
What is the number of ways of selecting 3 vowels from 5 vowels ?
Collections | Sequences |
---|---|
(a,e,i) | {(a,e,i), (a,i,e), (e,a,i), (e,i,a), (i,a,e),(i,e,a)} |
(a,e,o) | {(a,e,o), (a,o,e), (e,a,o), (e,o,a), (o,a,e), (o,e,a)} |
(a,e,u) | {(a,e,u), (a,u,e), (e,a,u), (e,u,a), (u,a,e), (u,e,a)} |
(a,i,o) | {(a,i,o), (a,o,i), (i,a,o), (i,o,a), (o,a,i), (o,i,a)} |
(a,i,u) | {(a,i,u), (a,u,i), (i,a,u), (i,u,a), (u,a,i), (u,i,a)} |
(a,o,u) | {(a,o,u), (a,u,o), (o,a,u), (o,u,a), (u,a,o), (u,o,a)} |
(e,i,o) | {(e,i,o), (e,o,i), (i,e,o), (i,o,e), (o,e,i), (o,i,e)} |
(e,i,u) | {(e,i,u), (e,u,i), (i,e,u), (i,u,e), (u,e,i), (u,i,e)} |
(e,o,u) | {(e,o,u), (e,u,o), (o,e,u), (o,u,e), (u,e,o), (u,o,e)} |
(i,o,u) | {(i,o,u), (i,u,o), (o,i,u), (o,u,i), (u,i,o), (u,o,i)} |
a e i o u
10
60
\frac{5!}{~2!~3!~}
3!
Sequences |
---|
{(a,e,i), (a,i,e), (e,a,i), (e,i,a), (i,a,e),(i,e,a)} |
{(a,e,o), (a,o,e), (e,a,o), (e,o,a), (o,a,e), (o,e,a)} |
{(a,e,u), (a,u,e), (e,a,u), (e,u,a), (u,a,e), (u,e,a)} |
{(a,i,o), (a,o,i), (i,a,o), (i,o,a), (o,a,i), (o,i,a)} |
{(a,i,u), (a,u,i), (i,a,u), (i,u,a), (u,a,i), (u,i,a)} |
{(a,o,u), (a,u,o), (o,a,u), (o,u,a), (u,a,o), (u,o,a)} |
{(e,i,o), (e,o,i), (i,e,o), (i,o,e), (o,e,i), (o,i,e)} |
{(e,i,u), (e,u,i), (i,e,u), (i,u,e), (u,e,i), (u,i,e)} |
{(e,o,u), (e,u,o), (o,e,u), (o,u,e), (u,e,o), (u,o,e)} |
{(i,o,u), (i,u,o), (o,i,u), (o,u,i), (u,i,o), (u,o,i)} |
Sequence or Collection?
15
P
VP
T
S
ABCD |
---|
ABDC |
ACBD |
ACDB |
ADBC |
ADCB |
BACD |
BADC |
BCAD |
BCDA |
BDAC |
BDCA |
CABD |
CADB |
CBAD |
CBDA |
CDAB |
CDBA |
DABC |
---|
DACB |
DBAC |
DBCA |
DCAB |
DCBA |
Given a class of 15 students, in how many ways can you form a committee of 4 members?
All these 4! = 24 sequences are equal in a collection
15
All these 4! = 24 sequences are equal in a collection
ABCD |
---|
ABDC |
ACBD |
ACDB |
ADBC |
ADCB |
BACD |
BADC |
BCAD |
BCDA |
BDAC |
BDCA |
CABD |
CADB |
CBAD |
CBDA |
CDAB |
CDBA |
DABC |
---|
DACB |
DBAC |
DBCA |
DCAB |
DCBA |
\frac{15!}{~~~~~(15-4)!~~~~~~}
\frac{~}{4!}
n \choose k
The number of ways of selecting kkk objects from given nnn objects is and is denoted as n(n−. 1)(n−2)...(n−k+1)n (n-1) (n-2) ... (n-k+1)
\frac{n!}{(n-k)!k!}
Collections
(some examples)
10
Consider 10 people in a meeting. If each person shakes hands with every other person in the room what is the total number of handshakes ?
Consider 10 people in a meeting. If each person shakes hands with every other person in the room what is the total number of handshakes ?
10
2
{10 \choose 2} = 45
You are going on a vacation and your suitcase has space for 3 shirts only? In how many ways can you fill the suitcase?
3
10
You are going on a vacation and your suitcase has space for 3 shirts only? In how many ways can you fill the suitcase?
3
10
You are going on a vacation and your suitcase has space for 3 shirts only? In how many ways can you fill the suitcase?
3
10
{10 \choose 3} = 120
There are 6 points on a 2 - dimensional plane such that no 3 points are collinear. How many segments can you draw from these 6 points?
6
2
{6 \choose 2} = 15
How many triangles can be formed from the vertices of a polygon of n sides?
n = 8
k = 3
{n \choose 3}
Collections
(with repetitions)
Recap
Sequences
without repetitions
with repetitions
Collections
without repetitions
with repetitions
\frac{n!}{(n-k)!}
n^k
\frac{n!}{(n-k)!k!}
?
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
10
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
How many breakfast combos containing 5 items can you form if you are allowed to have multiple servings of the same dish?
5
{14 \choose 5}
n original counters
{n+k-1 \choose k}
k-1 magic counters
The number of ways of selecting kkk objects from given nnn objects with repetitions is n(n−. 1)(n−2)...(n−k+1)n (n-1) (n-2) ... (n-k+1)
{n+k-1 \choose k}
(replicate any item which gets selected)
Summary
Sequences
without repetitions
with repetitions
Collections
without repetitions
with repetitions
\frac{n!}{(n-k)!}
n^k
\frac{n!}{(n-k)!k!}
{n+k-1 \choose k}
Collections
(+ multiplication principle)
Given a class of 7 boys and 8 girls, in how many ways can you form a committee of 4 members with 2 boys and 2 girls?
8
7
{8 \choose 2}
{7 \choose 2}
*
batsmen
keepers
pacers
spinners
7
2
4
3
Available
16
5
1
3
2
Select
11
{7 \choose 5}
{2 \choose 1}
{4 \choose 3}
{3 \choose 2}
{7 \choose 5}
{2 \choose 1}
{4 \choose 3}
{3 \choose 2}
*
*
*
Total =
(n−. 1)(n−2)...(n−k+1)n (n-1) (n-2) ... (n-k+1)
m_1 + m_2 + \dots + m_i = n
k_1 + k_2 + \dots + k_i = k
Given:n~items~of~i~different~types
{m_1 \choose k_1} * {m_2 \choose k_2} * \cdots * {m_i \choose k_i}
Form:collection~of~k~items
Collections
(+ subtraction principle)
3 cardiologists
4 diabetologists
2 neurologists
5 gynaecologists
7 general physicians
In how many ways can you form a 4-member committee containing at least one gynaecologist?
(total 21 doctors)
A = all possible committees of 4 members
B = all possible committees containing at least one gynaecologist
C = all possible committees containing no gynaecologist
count(A) = {21 \choose 4}
count(C) = {16 \choose 4}
count(B) = {21 \choose 4} - {16 \choose 4}
3 cardiologists
4 diabetologists
2 neurologists
5 gynaecologists
7 general physicians
(total 21 doctors)
Learning Objectives
What are collections and how do you count them?
Summary
Multiplication Principle
p*q*r*...
num. of choices at each step should be independent
address constraints first
Subtraction Principle
"at least one"
\frac{n!}{(n-k)!}
n^k
\frac{n!}{(n-k)!k!}
{n+k-1 \choose k}
Sequences
Collections
without repetitions
with repetitions
without repetitions
with repetitions
without repetitions
with repetitions
+ multiplication principle
+ multiplication/subtraction principle
CS6015: Lecture 25
By Mitesh Khapra
CS6015: Lecture 25
Lecture 25: Counting collections
- 1,363