1
00:00:00,260 --> 00:00:01,540
Welcome back.
2
00:00:01,540 --> 00:00:06,790
So we have been looking at how to count the
cardinality of sets.
3
00:00:06,790 --> 00:00:13,140
So this is what we call as Combinatorics,
so which is the branch of maths that involves
4
00:00:13,140 --> 00:00:15,440
counting.
5
00:00:15,440 --> 00:00:21,940
So most of the time the typical question is,
given a set S what is the cardinality of S,
6
00:00:21,940 --> 00:00:28,810
or in other words what is the size of the
set S, or how many elements are there in the
7
00:00:28,810 --> 00:00:31,170
set S.
8
00:00:31,170 --> 00:00:38,780
Now the question to be asked is that how is
the set given, and most of the time when we
9
00:00:38,780 --> 00:00:45,999
talk about this kind of problem, we say that
the set is given implicitly.
10
00:00:45,999 --> 00:00:50,850
It is not given explicitly, it has been described.
11
00:00:50,850 --> 00:00:57,940
For example, it can be something like, how
many elements of a particular universe set
12
00:00:57,940 --> 00:01:00,690
satisfy certain conditions.
13
00:01:00,690 --> 00:01:08,510
Or Equivalently put, how many ways can you
draw an element from the set, such that the
14
00:01:08,510 --> 00:01:10,420
element satisfies a set of conditions.
15
00:01:10,420 --> 00:01:19,400
Now we have been, we have some problem that
we should keep in our mind before we what
16
00:01:19,400 --> 00:01:21,610
we should like to solve.
17
00:01:21,610 --> 00:01:28,080
The first one being, how many n digit numbers
are there, in decimal representation with
18
00:01:28,080 --> 00:01:34,390
no consecutive digits same.
19
00:01:34,390 --> 00:01:44,920
The second, how many functions are there from
the set one to n to one to k, that are not
20
00:01:44,920 --> 00:01:45,920
decreasing.
21
00:01:45,920 --> 00:01:52,550
The third, how many ways to distribute n identical
toffees among k kids.
22
00:01:52,550 --> 00:01:59,659
And the last one is the number of 01 string
of length n, which does not have any consecutive
23
00:01:59,659 --> 00:02:00,890
zero.
24
00:02:00,890 --> 00:02:13,680
Now, question is that, how to count is something
an extremely challenging problem.
25
00:02:13,680 --> 00:02:22,459
Every problem, every set that we have to count
has its own complications and should be tackled
26
00:02:22,459 --> 00:02:23,459
differently.
27
00:02:23,459 --> 00:02:32,569
Even, some of the greats of math like, Srinivasa
Ramanujan has worked on counting for quite
28
00:02:32,569 --> 00:02:35,769
a big part of his life.
29
00:02:35,769 --> 00:02:42,370
And, here in this few lectures we will be
giving some tricks and tools, which will help
30
00:02:42,370 --> 00:02:44,409
you to attack problems.
31
00:02:44,409 --> 00:02:53,730
But again, as I told you, as I tell in every
class, you should use your creative mind to
32
00:02:53,730 --> 00:03:00,260
understand, which problem can be solved using
which trick, every problem is different, every
33
00:03:00,260 --> 00:03:02,230
problem is unique.
34
00:03:02,230 --> 00:03:11,419
Now, Till now, we have been looking at, we
have already looked at this problem of how
35
00:03:11,419 --> 00:03:20,239
many ways can I select k objects from n objects,
and we have looked at the two cases, namely
36
00:03:20,239 --> 00:03:26,750
what happens whether, are we allowed to pick
a same object multiple times, is repetition
37
00:03:26,750 --> 00:03:32,890
allowed, among the k selected objects.
38
00:03:32,890 --> 00:03:39,139
And, is the ordering of the objects in this
k objects matter.
39
00:03:39,139 --> 00:03:44,959
And we have seen how to solve all the four
cases.
40
00:03:44,959 --> 00:03:54,980
The next one that we looked at was, how many
ways can we distribute n balls into k bins.
41
00:03:54,980 --> 00:04:04,569
And there are few cases to be studied, particularly
whether the bins are distinguishable or not,
42
00:04:04,569 --> 00:04:09,519
whether the balls are distinguishable or not.
43
00:04:09,519 --> 00:04:19,630
If the balls are distinguishable, is the ordering
in the bins matter, can the bins be empty,
44
00:04:19,630 --> 00:04:20,810
and is there any other restrictions that can
be asked.
45
00:04:20,810 --> 00:04:27,940
And, in the last video, we looked at this
problem and we solved some of the parts of
46
00:04:27,940 --> 00:04:29,230
this problem.
47
00:04:29,230 --> 00:04:44,670
Namely we did solve the case when the bins
are labelled, and items are indistinguishable,
48
00:04:44,670 --> 00:04:48,420
and in case bins are labelled, but bins can
be empty.
49
00:04:48,420 --> 00:04:57,190
We also solved, when the items are distinguishable
and ordering matters or does not matter, either
50
00:04:57,190 --> 00:04:58,310
case we solved that.
51
00:04:58,310 --> 00:05:04,280
But we are left with two of the problems,
which we will be tackling in this video, namely
52
00:05:04,280 --> 00:05:12,930
if bins are labelled but cannot be empty,
then how do you solve it.
53
00:05:12,930 --> 00:05:19,310
And also we were left with the case when bins
are unlabelled.
54
00:05:19,310 --> 00:05:29,090
Now, lets to before start working on those
things, let us do a little bit study of the
55
00:05:29,090 --> 00:05:31,470
theory behind it.
56
00:05:31,470 --> 00:05:39,000
The important thing is that, if A and B are
two sets and size of A is p and size of B
57
00:05:39,000 --> 00:05:47,050
is q, what is the size of A union B. Note
that, this is very similar to the additive
58
00:05:47,050 --> 00:05:50,300
law that we studied two videos ago.
59
00:05:50,300 --> 00:05:59,230
It told that if A and B does not have anything
in common or in other words, what in told
60
00:05:59,230 --> 00:06:10,300
was that if A intersection B is empty,meaning
if the cardinality of this one is zero, then
61
00:06:10,300 --> 00:06:19,830
the cardinality of A union B, either A happens
or B happens is p plus q.
62
00:06:19,830 --> 00:06:29,940
But what happens if this is not zero, for
example, if I have this as the set, so if
63
00:06:29,940 --> 00:06:42,060
this is universal set Z, where we are working
on, if this is A and this is B, and A intersection
64
00:06:42,060 --> 00:06:47,980
B does have some place here, how do you solve
it.
65
00:06:47,980 --> 00:06:57,030
Now as you can see, from the picture in some
sense, what happens if I look at size of A
66
00:06:57,030 --> 00:07:06,550
plus size of B. So in the case that, okay,
let me just complete this line, size of, B
67
00:07:06,550 --> 00:07:15,390
is this set, and A is this set.
68
00:07:15,390 --> 00:07:25,520
Now note that every point here inside A union
B has been selected once, if it is somewhere
69
00:07:25,520 --> 00:07:30,710
here, and once if it is somewhere here.
70
00:07:30,710 --> 00:07:37,349
But if it in the intersection, it has been
counted twice, right.
71
00:07:37,349 --> 00:07:45,310
So it is like, if you have to place two round
paper cuts, one over the other, you need to
72
00:07:45,310 --> 00:07:52,030
cut away, one should cut away this chunk out
once.
73
00:07:52,030 --> 00:07:59,900
So, if you subtract A intersection B, you
should be getting A union B.
74
00:07:59,900 --> 00:08:07,420
And that is a very crucial thing, that A union
B is size of A plus size of B minus intersection
75
00:08:07,420 --> 00:08:23,070
of A and B. Now, so what is the answer, answer
is of course that A union B is size of A plus
76
00:08:23,070 --> 00:08:25,820
sign of B minus A intersection B.
77
00:08:25,820 --> 00:08:35,550
Now, what happens if I have three sets, we
are back to the same Venn diagram for set
78
00:08:35,550 --> 00:08:47,960
we always look at for such kind of situations,
if we have A, B and C, then you can first
79
00:08:47,960 --> 00:08:54,260
pick up all of them, you can first cover all
of them.
80
00:08:54,260 --> 00:09:17,240
But then, say this is A, this is B and this
is C. Now As you can see, that this space
81
00:09:17,240 --> 00:09:27,210
of A intersection C has been counted twice,
first by A and then by C. So i need to subtract
82
00:09:27,210 --> 00:09:30,820
at least once one of this away, right.
83
00:09:30,820 --> 00:09:38,930
So subtract A intersection C, and also I have
to similarly subtract A intersection B and
84
00:09:38,930 --> 00:09:51,480
I have to subtract A intersection B, sorry
I have to subtract B intersection C. Now,
85
00:09:51,480 --> 00:10:03,480
what happens in this case of this small area,
this was counted once for A, once by B, once
86
00:10:03,480 --> 00:10:12,230
by C. It was subtracted once by A intersection
C, subtracted once by A intersection B, subtracted
87
00:10:12,230 --> 00:10:18,200
once by B intersection C, that means, right
now this one has not contributed anything.
88
00:10:18,200 --> 00:10:26,500
So I need to now add it up, so I have to add
this part, A intersection B intersection C.
89
00:10:26,500 --> 00:10:39,350
So in other words what I will get is that,
I will get that A union B union C is equal
90
00:10:39,350 --> 00:10:47,510
to first adding the sets individually, then
subtracting the pairwise intersection then
91
00:10:47,510 --> 00:10:48,970
adding the threewise intersection.
92
00:10:48,970 --> 00:10:59,700
Now, question is that what happens in the
case of 4 case, if I have four sets A, B,
93
00:10:59,700 --> 00:11:07,250
C, D, in that case what is the size A union
B union C union D.
94
00:11:07,250 --> 00:11:18,160
Is there a formula for it and we do have one
and that is called the principle of inclusion/exclusion
95
00:11:18,160 --> 00:11:25,120
and it basically talks about that if I have
n sets A1 to An, then what is the size of
96
00:11:25,120 --> 00:11:29,250
A1 union A2 union till An.
97
00:11:29,250 --> 00:11:42,660
So the size of the union is first add the
individual sets, then subtract all the pairs
98
00:11:42,660 --> 00:11:48,900
of intersections, then add all the triple
intersections, then subtract all the four
99
00:11:48,900 --> 00:11:50,310
intersections.
100
00:11:50,310 --> 00:11:59,960
In some sense you are adding, subtracting,
adding, subtracting and it keeps on going
101
00:11:59,960 --> 00:12:08,100
on till the last one where you add or subtract
depending on what is the size of n, if n is
102
00:12:08,100 --> 00:12:13,210
odd or even, it is minus one power n plus
1.
103
00:12:13,210 --> 00:12:18,922
You add or subtract the intersection of all
the sets.
104
00:12:18,922 --> 00:12:20,840
Now this is a theorem.
105
00:12:20,840 --> 00:12:25,990
I am not going to prove this theorem.
106
00:12:25,990 --> 00:12:31,220
I leave this to you guys to check that this
theorem is indeed correct.
107
00:12:31,220 --> 00:12:34,800
You can prove this theorem using induction.
108
00:12:34,800 --> 00:12:41,710
This particular theorem is an extremely powerful
tool for counting.
109
00:12:41,710 --> 00:12:49,690
So writing is in a nice way, we do get this
particular expression.
110
00:12:49,690 --> 00:13:01,040
So once we have this principle of inclusion/exclusion,
we can use it to solve a many of our problems.
111
00:13:01,040 --> 00:13:04,430
So let us start with this problem.
112
00:13:04,430 --> 00:13:13,120
Where We say that there are n constables in
a police station.
113
00:13:13,120 --> 00:13:19,230
You have to divide it into four projects,
project 1, project 2, project 3, project 4.
114
00:13:19,230 --> 00:13:24,570
No constable can be part of more than one
project and every constable should be part
115
00:13:24,570 --> 00:13:28,810
of some project and also at least one constable
should be assigned to every project.
116
00:13:28,810 --> 00:13:33,070
None of the project should be empty.
117
00:13:33,070 --> 00:13:37,730
Now, how do you solve it?
118
00:13:37,730 --> 00:13:45,700
If you remember, if we do not have this particular
thing that every project has at least one
119
00:13:45,700 --> 00:13:52,700
constable assigned, then we saw that the first
constable can be put in either of the four
120
00:13:52,700 --> 00:13:59,220
projects, the second constable can be put
in either of the four projects, and so on,
121
00:13:59,220 --> 00:14:07,190
so the total number of ways of assigning the
constable in the four projects is four power
122
00:14:07,190 --> 00:14:09,649
n, right.
123
00:14:09,649 --> 00:14:21,200
But here unfortunately, it is a possibility
that some of the projects might be empty.
124
00:14:21,200 --> 00:14:23,730
So we need to get rid of them.
125
00:14:23,730 --> 00:14:33,000
If we want to ensure that every project have
some constable, then we have to subtract all
126
00:14:33,000 --> 00:14:45,500
the possible, so subtract all distributions
where at least one project is empty.
127
00:14:45,500 --> 00:15:02,950
Now, how do you do it.
128
00:15:02,950 --> 00:15:05,529
So let me define this new class Ai.
129
00:15:05,529 --> 00:15:09,900
Ai is the set of all distributions.
130
00:15:09,900 --> 00:15:18,910
Distribution meaning of n constables into
projects where project i is empty or it does
131
00:15:18,910 --> 00:15:23,670
not have any constable.
132
00:15:23,670 --> 00:15:42,899
Now if I have defined this Ai in this way,
then how do I define the set of all distributions
133
00:15:42,899 --> 00:15:44,029
that are empty.
134
00:15:44,029 --> 00:15:58,899
So the set of all distributions that are empty
is nothing but union over Ai or rather in
135
00:15:58,899 --> 00:16:08,220
this case it will be A1, all the distribution
where the first project is empty or all the
136
00:16:08,220 --> 00:16:12,560
distribution where the second project is empty,
or all the distribution where the third project
137
00:16:12,560 --> 00:16:19,700
is empty, or all the distribution where the
fourth project is empty and substract them
138
00:16:19,700 --> 00:16:21,180
out, right.
139
00:16:21,180 --> 00:16:29,230
So we can now subtract, so this is the set
of all assignments, or all distributions of
140
00:16:29,230 --> 00:16:38,570
constables in to four projects where some
of or at least one of the project is empty
141
00:16:38,570 --> 00:16:46,360
and when I subtract that one from four power
n, I get my required answer.
142
00:16:46,360 --> 00:16:56,110
Now by the principle of inclusion/exclusion,
I can write this one as, so all I have to
143
00:16:56,110 --> 00:17:01,450
do is that I have to write this particular
term, right, the unions.
144
00:17:01,450 --> 00:17:03,959
So let me just do not worry about this one.
145
00:17:03,959 --> 00:17:06,740
This one, what is this term?
146
00:17:06,740 --> 00:17:14,199
This is summation of A1 plus A2 plus A3 plus
A4.
147
00:17:14,199 --> 00:17:15,630
Now what is A1 plus A2 plus A3 plus A4?
148
00:17:15,630 --> 00:17:18,350
What is A1?
149
00:17:18,350 --> 00:17:25,260
A1 is the number of ways in which the i-th
project is empty.
150
00:17:25,260 --> 00:17:27,839
That means nobody goes to the i-th project.
151
00:17:27,839 --> 00:17:33,840
How many such ways can you distribute n constable
into four projects, where the first project
152
00:17:33,840 --> 00:17:34,840
is empty.
153
00:17:34,840 --> 00:17:44,840
That means it is the same way as distributing
n constable into the project 2, 3, or 4.
154
00:17:44,840 --> 00:17:47,299
So this one is equals to 3 power n.
155
00:17:47,299 --> 00:17:56,241
The first one, The constables can go to project
2, 3 or 4, Similarly, this is also 3 power
156
00:17:56,241 --> 00:17:57,241
n.
157
00:17:57,241 --> 00:18:08,290
Now, by principle of inclusion/exclusion,
I have to subtract A1 intersection A2, I have
158
00:18:08,290 --> 00:18:11,650
to subtract A2 intersection A3 and so on.
159
00:18:11,650 --> 00:18:15,360
Now what is A1 intersection A2?
160
00:18:15,360 --> 00:18:26,360
A1 intersection A2 is the set of all distributions
where the first and second project are empty,
161
00:18:26,360 --> 00:18:31,320
right and this can of course happen with that
both the projects are empty, that means it
162
00:18:31,320 --> 00:18:38,750
is same as dividing n constable into only
project 3 and project 4, which is 2 power
163
00:18:38,750 --> 00:18:39,750
n.
164
00:18:39,750 --> 00:18:48,890
And all of them are same and similarly when
we have to do it for A1 intersection A2 intersection
165
00:18:48,890 --> 00:18:54,720
A3, these are the number of distributions
where project 1, project 2, and project 3
166
00:18:54,720 --> 00:19:05,580
are all empty and this can only happen with
one way where all of them goes to project
167
00:19:05,580 --> 00:19:08,040
4 and so on.
168
00:19:08,040 --> 00:19:18,620
Note that this is what, so the main idea is
that intersection of Ai can be sometimes very
169
00:19:18,620 --> 00:19:21,560
easy to compute as in this case.
170
00:19:21,560 --> 00:19:26,750
And if intersection of Ai is easy to compute,
then by the principle of inclusion/exclusion,
171
00:19:26,750 --> 00:19:36,460
I can write cardinality of the union of the
sets and by doing so, we can get the number.
172
00:19:36,460 --> 00:19:44,890
It will not be a very compact number, but
it is still something, which has a expression.
173
00:19:44,890 --> 00:19:52,560
So infact we can write down the expression
of that exactly.
174
00:19:52,560 --> 00:19:59,580
So if there are n objects n distinguishable
ball and k labelled bins, how many ways can
175
00:19:59,580 --> 00:20:08,670
we place n balls in k bins when ordering inside
the bin does not matter, but no bins can be
176
00:20:08,670 --> 00:20:13,460
left empty, it is k power n minus this way.
177
00:20:13,460 --> 00:20:21,490
Now why this k choose i because k choose i
is the number of ways in which I can choose
178
00:20:21,490 --> 00:20:25,549
i of the sets and take intersection of them,
right.
179
00:20:25,549 --> 00:20:36,890
I have to for example this should be like
k power n minus intersection of all the A1,
180
00:20:36,890 --> 00:20:38,120
A2 is right.
181
00:20:38,120 --> 00:20:51,600
So all the A1, A2 is k choose 2 times k minus
1 power n plus all the triples k choose 3
182
00:20:51,600 --> 00:20:59,600
and all the triples with value Ai intersection
Aj intersection Ak is k minus 2 power n and
183
00:20:59,600 --> 00:21:01,930
so on.
184
00:21:01,930 --> 00:21:09,520
So this gives us a kind of a close form expression,
not exactly a close form expression, but an
185
00:21:09,520 --> 00:21:20,169
expression of this kind for getting the number
of ways in distributing n balls into k bins
186
00:21:20,169 --> 00:21:23,080
with no empty bin.
187
00:21:23,080 --> 00:21:33,460
So we can use the same technique, when ranking
inside the bins matter.
188
00:21:33,460 --> 00:21:42,429
If you remember, ranking inside the bin without
when they are empty bins were allowed, was
189
00:21:42,429 --> 00:21:43,429
this one.
190
00:21:43,429 --> 00:21:51,679
Now, we can do the identically same thing
with the principle of inclusion exclusion
191
00:21:51,679 --> 00:21:57,220
and we can get this.
192
00:21:57,220 --> 00:22:06,360
So by doing so, we have been able to fill
up this particular matrix.
193
00:22:06,360 --> 00:22:16,770
Now let us try to see if we can solve the
other three possibilities, namely when bins
194
00:22:16,770 --> 00:22:17,770
are unlabelled.
195
00:22:17,770 --> 00:22:19,460
Now, when bins are unlabelled for example.
196
00:22:19,460 --> 00:22:32,590
This is a typical example when you have to
the divide constable into four groups and
197
00:22:32,590 --> 00:22:42,919
we do not care about which group is assigned
to which project, how many ways can you do
198
00:22:42,919 --> 00:22:43,919
it?
199
00:22:43,919 --> 00:22:53,630
Now the idea is that if say I assign constable
C1, C2, C3 to project 1 and C4 to project
200
00:22:53,630 --> 00:23:07,299
2 and C5 to project 3 and C6, C7 to project
4, note that if I permute this project 1 to
201
00:23:07,299 --> 00:23:13,200
project, if you do not have any name for the
projects.
202
00:23:13,200 --> 00:23:27,490
In that case if I change the project ordering
to P2, P3, P1, P4, any of the ordering are
203
00:23:27,490 --> 00:23:34,510
equivalent and they would have been counted
in when we did not take care of the fact that
204
00:23:34,510 --> 00:23:36,710
they are not indistinguishable.
205
00:23:36,710 --> 00:23:49,720
By using this technique of the equivalent
classes, we can see that every distribution
206
00:23:49,720 --> 00:24:00,480
with the labelled projects has belongs to
an equivalent class of the same size namely
207
00:24:00,480 --> 00:24:04,940
the number of ways you can permute these four
things, which is four factorial.
208
00:24:04,940 --> 00:24:13,640
So by the technique of this equivalence partitioning,
we can now just divide.
209
00:24:13,640 --> 00:24:26,172
So if I have to solve this thing of n distinguishable
balls into k unlabelled bins, we have to take
210
00:24:26,172 --> 00:24:36,280
in the case when I have exactly k bins that
are filled, no empty, and I divide it by k
211
00:24:36,280 --> 00:24:38,480
factorial and I get the answer.
212
00:24:38,480 --> 00:24:48,870
Note that, if I have not taken the number
here, when everything was not empty, then
213
00:24:48,870 --> 00:25:00,150
things could have been a bit more weird.
214
00:25:00,150 --> 00:25:07,320
So by the same argument, by the way, this
particular number, so this is the number of
215
00:25:07,320 --> 00:25:18,100
ways in which one can distribute n distinguishable
balls into k unlabelled bins when the ordering
216
00:25:18,100 --> 00:25:28,230
in the bins does not matter, but no bins can
be left empty.
217
00:25:28,230 --> 00:25:40,260
This is called the Sterling Number of Second
Kind denoted by S (n, k).
218
00:25:40,260 --> 00:25:53,870
Similarly, we can do it for the third, for
the last of this table, which is when ordering
219
00:25:53,870 --> 00:26:01,780
inside matters does not matter and bins are
unlabelled.
220
00:26:01,780 --> 00:26:12,850
Now with this, we have done basically all
the cases except this case namely when items
221
00:26:12,850 --> 00:26:18,750
are indistinguishable and bins are unlabelled.
222
00:26:18,750 --> 00:26:21,630
How many ways can you do it?
223
00:26:21,630 --> 00:26:30,190
Now, This is a very hard problem and we will
be talking about this problem in the next
224
00:26:30,190 --> 00:26:31,190
video.
225
00:26:31,190 --> 00:26:32,170
Thank you.