1
00:00:01,319 --> 00:00:07,080
Welcome back, in the last few videos, we have
been studying recurrence relations.
2
00:00:07,080 --> 00:00:14,550
So recurrence relations is basically an equation
that recursively defines a sequence of values.
3
00:00:14,550 --> 00:00:25,480
There are some initial terms and the nth term
is defined as a function of the preceding
4
00:00:25,480 --> 00:00:26,480
terms.
5
00:00:26,480 --> 00:00:34,130
Recurrence relations have been used extensively
for combinatorics, analysis of algorithms,
6
00:00:34,130 --> 00:00:41,850
in computational biology, in theoretical economics
and in various other subjects.
7
00:00:41,850 --> 00:00:51,790
In the last week, sorry, couple of videos,
earlier we saw how to use the recurrence relations
8
00:00:51,790 --> 00:00:58,379
for modelling some of the counting problems.
9
00:00:58,379 --> 00:01:04,449
Now once you solve, when you model some of
the counting problems, you have to solve the
10
00:01:04,449 --> 00:01:07,040
recurrence relations in some way.
11
00:01:07,040 --> 00:01:17,710
So here some of the examples that appears
in real life, say for example, T(1) equals
12
00:01:17,710 --> 00:01:29,710
to 1 and T(n) equals to 2 plus T(n-1) or T(1)
equals to 2 and T(2) equals to 3 and T(n)
13
00:01:29,710 --> 00:01:39,920
equals to T(n-1) plus T(n-2) or this is the
one that came from the Tower of Hanoi problem.
14
00:01:39,920 --> 00:01:50,140
T1=1, sorry, H(1) equals to 1, H(2) equals
to 3 and H(n) equals to 2 times H (n-1) plus
15
00:01:50,140 --> 00:01:57,610
1, or this is the one that come from the Fibonacci
sequence, F(1) equals to 1, F(2) equals to
16
00:01:57,610 --> 00:02:06,979
1 and F(n) equals to F(n-1) plus F(n-2), or
this one that comes from the binary search
17
00:02:06,979 --> 00:02:16,730
algorithm, b(1) equals to 1 and b(n) equals
to b (n over 2) + 1, or this one that comes
18
00:02:16,730 --> 00:02:24,290
from the merge sort algorithm M(1) equals
to 1 and M(n) equals to 2 times M( n over
19
00:02:24,290 --> 00:02:34,510
2) + n, or this one which comes from, what
is known as Catalan number C(1) equals to
20
00:02:34,510 --> 00:02:42,530
1 and C(n+1) equals to summation i= 0 to n
C(i) C(n-i).
21
00:02:42,530 --> 00:02:49,540
Now these are some of the recurrence relations
that appear in real life, these are the very
22
00:02:49,540 --> 00:02:52,150
small sample of them.
23
00:02:52,150 --> 00:02:55,950
Now the main question is how do you solve
these recurrence relations?
24
00:02:55,950 --> 00:03:01,150
So these recurrence relations are ofcourse
used to module various problems, but once
25
00:03:01,150 --> 00:03:06,530
you model them into a recurrence relations,
the next step is to solve them.
26
00:03:06,530 --> 00:03:13,680
In the last video, we saw a technique of solving
them.
27
00:03:13,680 --> 00:03:21,930
And we told these are the techniques that
first of all guess the solution and then proves
28
00:03:21,930 --> 00:03:23,700
using induction.
29
00:03:23,700 --> 00:03:31,490
We saw that if we can guess the solution correct,
then proving it by induction possibly not
30
00:03:31,490 --> 00:03:37,890
to hard a problem, it is like the typical
induction problem.
31
00:03:37,890 --> 00:03:41,940
The main issue is how do you guess the solution?
32
00:03:41,940 --> 00:03:47,520
Now guessing the solution can really be a
challenging problem.
33
00:03:47,520 --> 00:03:51,570
So we will be dedicating quiet a number of
lectures on guessing the solution.
34
00:03:51,570 --> 00:04:03,390
Today we will be looking at the first and
the simplest technique of guessing the solution.
35
00:04:03,390 --> 00:04:13,870
So here is it, so technique one, the idea
is just unfolding the definitions.
36
00:04:13,870 --> 00:04:20,590
What do I mean by unfolding the definitions?
37
00:04:20,590 --> 00:04:26,120
So let us look at some of the examples and
you will understand what do I mean by that?
38
00:04:26,120 --> 00:04:32,810
Note that these are not formal proofs, these
are mere guessing which might work or might
39
00:04:32,810 --> 00:04:39,070
not work and whether it works or not, of course
you have to go back to the induction and prove
40
00:04:39,070 --> 00:04:42,710
it and only then we get a formal proof.
41
00:04:42,710 --> 00:04:49,820
So this is whatever I am going to say it now
is how to guess this step?
42
00:04:49,820 --> 00:05:01,560
Say if T(1)=1 and T(n)=2+ T(n-1), so let us
write down here, T(n)= 2+ T(n-1).
43
00:05:01,560 --> 00:05:07,180
Now what is T(n-1), I can recursively now
open up, right?
44
00:05:07,180 --> 00:05:18,330
so T(n-1) is 2+T(n-2), Okay, let us write
down once again, 2+ T(n-3), okay, let us write
45
00:05:18,330 --> 00:05:22,590
down once again, 2 + T(n-4).
46
00:05:22,590 --> 00:05:34,260
So this is where comes up the big leap of
faith, your kind of say that okay when there
47
00:05:34,260 --> 00:05:40,400
are some 4 of the 2’s here, I have a 4 here.
48
00:05:40,400 --> 00:05:46,270
When I have 3 of the 2’s here, I have 3
here.
49
00:05:46,270 --> 00:05:52,100
When I have 2 of the 2’s here, I have 2
here.
50
00:05:52,100 --> 00:05:54,650
When I have one 2 here, I have 1 here.
51
00:05:54,650 --> 00:06:09,290
So if I have keep on doing this way, I will
get a 2+2+, for some k of them + T(n-k), now
52
00:06:09,290 --> 00:06:10,730
this is a leap of faith.
53
00:06:10,730 --> 00:06:16,780
Okay, again as I told it is a guessing work,
right.
54
00:06:16,780 --> 00:06:22,520
Now this number is somehow to vanish.
55
00:06:22,520 --> 00:06:37,540
The idea is that, the initial things, here
T(1)=1, gives us the hint, so we have to set,
56
00:06:37,540 --> 00:06:46,360
so here if k=n-1, then T(n-k) = T(1) is equals
to 1.
57
00:06:46,360 --> 00:06:49,880
So I have to put this one as n-1.
58
00:06:49,880 --> 00:07:05,450
So in fact if I remove this k here and instead
I write here n-1, and I remove this one n-1,
59
00:07:05,450 --> 00:07:08,200
what do I get?
60
00:07:08,200 --> 00:07:24,160
Here I should get 2 times n-1, because I have
2(n-1) + T(1), which is 2n-2+1, which is 2n-1,
61
00:07:24,160 --> 00:07:25,160
okay.
62
00:07:25,160 --> 00:07:37,760
So this by doing so we have guess that Tn=2n-1,
again also it might seem very formal way of
63
00:07:37,760 --> 00:07:46,280
proving that T(n) =2(n-1), the fact is that
it still not a correct proof, a complete proof,
64
00:07:46,280 --> 00:07:49,460
because we have these dot, dot, dots here.
65
00:07:49,460 --> 00:07:53,810
There was a big leap of faith from this to
this.
66
00:07:53,810 --> 00:08:00,770
May be our intuitions are correct and we get
the right answer and in which case we go ahead
67
00:08:00,770 --> 00:08:10,110
and prove it using induction, right; and there
are times, there are examples where this leap
68
00:08:10,110 --> 00:08:15,120
of faith may not be exactly correct.
69
00:08:15,120 --> 00:08:21,990
But this is one way of kind of guessing what
the number is.
70
00:08:21,990 --> 00:08:42,460
So in this case, we have T(n)= 2n-1, is the
guess and you prove it by induction.
71
00:08:42,460 --> 00:08:49,110
We had seen in the last video that this is
indeed right way of guessing it and we have
72
00:08:49,110 --> 00:08:51,810
or right guess by proving it by induction.
73
00:08:51,810 --> 00:09:05,089
Now let us move on to the next example, so
here T(n)= n+ T (n-1), again we have to let
74
00:09:05,089 --> 00:09:12,620
us keep on unfolding a definition, so T(n)=
n+ T (n-1), unfold this T(n-1), this is (n-1)
75
00:09:12,620 --> 00:09:14,120
+ T(n-2).
76
00:09:14,120 --> 00:09:28,660
Now again if I unfold it more, this is (n-2)
+ T(n-3) and here again now let us do a leap
77
00:09:28,660 --> 00:09:42,580
of faith, as you see here, when I have 3 here,
I keep on doing it till 2, when I 2 here,
78
00:09:42,580 --> 00:10:00,990
I keep on doing it till 1, so may be if I
keep on doing this thing till n-k, I have
79
00:10:00,990 --> 00:10:02,950
T(n-k+1), right.
80
00:10:02,950 --> 00:10:04,910
Sorry, T(n-(k+1)).
81
00:10:04,910 --> 00:10:20,811
Now again we have to somehow disappears this
term, so the idea is again that we have to
82
00:10:20,811 --> 00:10:50,550
get this n-k+1 as 1, so in other words, if
I take k to be =n-2, right, what we had?
83
00:10:50,550 --> 00:11:06,029
Then n-(k+1) =1, so in that case what should
we get is that, I keep on going it, +n-k,
84
00:11:06,029 --> 00:11:19,490
which is n-2 + T(1), now T(1) =1 and this
keeps on going and this n-(n-2) is nothing
85
00:11:19,490 --> 00:11:30,760
but 2 and the T(1)=1, so in fact we get the
sum over the first n integers, which is n(n+1)/2.
86
00:11:30,760 --> 00:11:48,550
So by doing so, we have guess that T(n)=n(n+1)/2,
now again as I told you this is a leap of
87
00:11:48,550 --> 00:11:55,350
faith, because there was a leap of faith here
and hence this is just a case, so formally
88
00:11:55,350 --> 00:12:08,730
proving it we have to solve it by induction
and verify that our guess is indeed right.
89
00:12:08,730 --> 00:12:18,600
So again the simple idea is, keep on unfolding
the definition and it will be possibly we
90
00:12:18,600 --> 00:12:26,420
are able to guess the value and in this case
we did guess Tn=n(n+1)/2 and we then prove
91
00:12:26,420 --> 00:12:28,040
it by induction.
92
00:12:28,040 --> 00:12:41,070
As I told you, most of the time the guess
does work correctly if we can unfold it in
93
00:12:41,070 --> 00:12:44,890
a right way.
94
00:12:44,890 --> 00:12:56,080
Let us look at one more example, is the tower
of Hanoi problem where H(1) =1 and H(n)= 1+
95
00:12:56,080 --> 00:13:02,230
2 times H(n-1), here H(n)=1+2H(n-1), so this
is actually quite interesting, so this one
96
00:13:02,230 --> 00:13:17,709
is 2 times now here, 1+ 2times H(n -1), sorry
(n-2), which is 1+2+2 times H(n-2), sorry
97
00:13:17,709 --> 00:13:33,580
not 2 times, this is in fact 2 times 2 is
4 times.
98
00:13:33,580 --> 00:13:52,070
Let us open it again, 1+2+ 4 times, what is
H(n-2)?, is 1 + twice H(n-3), which is 1+2+4+8H(n-3).
99
00:13:52,070 --> 00:13:58,020
Now this is where you really have to take
a leap of faith, so let us write this one
100
00:13:58,020 --> 00:14:01,950
here, 1+2+4+, what is 8?
101
00:14:01,950 --> 00:14:09,180
8 is 2 power 3 H(n-3).
102
00:14:09,180 --> 00:14:20,020
Note that here it was also 2 power 2 and I
had 2 here, 2 power 1 and I had 1 here.
103
00:14:20,020 --> 00:14:34,360
So again by the complete leap of faith, we
can write it as 1+2+4+8+2 power k+ 2 power
104
00:14:34,360 --> 00:14:39,830
k+1 and when I have k+1, I have H(n-(k+1)).
105
00:14:39,830 --> 00:14:57,220
Now here again we need to make this one disappear,
so again I have H(1) equals to 1, so again
106
00:14:57,220 --> 00:14:59,600
take k to be equals to n-2.
107
00:14:59,600 --> 00:15:17,480
If I take k=n-2, then n-k+1 =1, so when this
becomes T(1), this becomes T(1), which is
108
00:15:17,480 --> 00:15:28,000
1, so I get 1+2+4+8+2 power k which is n-2+2
power n-1 times T(1) and since T(1)=1, so
109
00:15:28,000 --> 00:15:33,180
I can forget this statement.
110
00:15:33,180 --> 00:15:49,750
And so I get this number, which is a GP series
and the GP series as the 2 power n-1.
111
00:15:49,750 --> 00:15:59,640
So I guess that H(n)=2 power n-1, so this
one clearly was slightly more complicated
112
00:15:59,640 --> 00:16:05,200
than the earlier ones, but again here there
was a massive leap of faith here, when we
113
00:16:05,200 --> 00:16:17,839
guess that this 3,3 and similarly here 2,
2 and so on exist.
114
00:16:17,839 --> 00:16:24,170
And so by doing so we have managed to guess
it, but we need to prove that the guess is
115
00:16:24,170 --> 00:16:28,980
right again by induction.
116
00:16:28,980 --> 00:16:35,860
It so happens that in this case, we guess
it indeed right and we saw it last time that
117
00:16:35,860 --> 00:16:47,190
we can guess this one and we do get the induction,
by induction we can prove the statement.
118
00:16:47,190 --> 00:16:59,350
So the basic idea that we learned from this
video is that if have given a particular recurrence
119
00:16:59,350 --> 00:17:17,559
relation like this and if you can unfold it,
maybe you can try to guess the number.
120
00:17:17,559 --> 00:17:31,049
The problem is
that they are complicated ones like this,
121
00:17:31,049 --> 00:17:42,899
F(n)=F(n-1) + F(n-2), now we can try to unfold
it by saying okay, F(n)=F(n-1) + F(n-2), where
122
00:17:42,899 --> 00:17:53,350
F(n-1)= F(n-2)+ F(n-3) + F(n-2), so I get
2 times F(n-2) + F(n-3) which will remain
123
00:17:53,350 --> 00:18:03,179
2 times F(n-3)+F(n-4)+F(n-3) which is equals
to 3 times F(n-3)+ 2 times F(n-4) and of course
124
00:18:03,179 --> 00:18:16,399
it is clear if I keep on doing it and but
then as you can see I can write down the next
125
00:18:16,399 --> 00:18:20,980
step directly and this will become something
like 5F(n-4)+3 F(n-5).
126
00:18:20,980 --> 00:18:35,739
Since, particularly no pattern coming out
in this recurrence relations.
127
00:18:35,739 --> 00:18:41,720
So in fact for this kind of recurrence relations,
unfolding will not help.
128
00:18:41,720 --> 00:18:49,399
I leave you guys to check and verify and convince
yourselves that here by unfolding you will
129
00:18:49,399 --> 00:18:58,179
not be able to guess the actual value, in
fact guessing the actual value is quiet complicated
130
00:18:58,179 --> 00:18:59,179
here.
131
00:18:59,179 --> 00:19:08,309
Here is the actual guess and you can see by
looking at this expression, it is not something
132
00:19:08,309 --> 00:19:14,690
that is easy to guess, right.
133
00:19:14,690 --> 00:19:24,789
Also we have other kind of formulas like this
one, where b(1)=1 and b(n)=b(n/2)+1, where
134
00:19:24,789 --> 00:19:34,570
this is, this one denotes the integer that
is bigger than or equal to n/2, so if n=9,
135
00:19:34,570 --> 00:19:40,230
then n/2, with these 2 things here is 5, right.
136
00:19:40,230 --> 00:19:48,789
So with this kind of an expression, unfortunately
there is no clean guess can be made because
137
00:19:48,789 --> 00:20:02,289
of this extra bit of weird thing that are
there, this what we call as ceilings right.
138
00:20:02,289 --> 00:20:08,220
So there are expressions of this form where
either the guessing is too hard or we do not
139
00:20:08,220 --> 00:20:11,140
have a very clean guessing for them.
140
00:20:11,140 --> 00:20:17,279
How to attack this particular kind of recurrence
relation we will be doing in the next couple
141
00:20:17,279 --> 00:20:18,279
of weeks.
142
00:20:18,279 --> 00:20:19,210
Thank you.