1
00:00:01,590 --> 00:00:02,250
Hello everyone.

2
00:00:02,250 --> 00:00:03,540
Welcome to this new recession.

3
00:00:03,540 --> 00:00:05,010
So what do we do today.

4
00:00:05,010 --> 00:00:10,140
So we will try to solve one more problem with the help of the occasion so so that our understanding

5
00:00:10,140 --> 00:00:11,520
of religion can become better.

6
00:00:11,610 --> 00:00:12,310
OK.

7
00:00:12,450 --> 00:00:16,350
So the name of the problem that we are going to solve today is multiplication.

8
00:00:16,460 --> 00:00:17,950
Okay.

9
00:00:18,480 --> 00:00:19,880
So what do we do.

10
00:00:19,890 --> 00:00:22,440
So given two numbers we have to merge to play them.

11
00:00:22,440 --> 00:00:22,700
OK.

12
00:00:22,740 --> 00:00:27,600
So there are two numbers m and n and we have to multiply these two numbers.

13
00:00:27,630 --> 00:00:33,780
So that is M and doing OK so the one way to solve this problem is to simply use the multiply operator.

14
00:00:34,110 --> 00:00:36,180
But we don't have to use multiply or break that.

15
00:00:36,180 --> 00:00:38,090
We can only use additional played that.

16
00:00:38,100 --> 00:00:38,360
OK.

17
00:00:38,370 --> 00:00:42,060
We can only use plus operator or minus OPERATOR OK.

18
00:00:42,090 --> 00:00:44,680
We cannot use the money to play operator.

19
00:00:44,720 --> 00:00:48,150
Now I think we have hour to solve this problem but I'm not sure.

20
00:00:48,180 --> 00:00:52,200
So if you are more dipping into numbers I mean when can I write it like this.

21
00:00:52,200 --> 00:00:56,320
Basically I'm adding the same number and times.

22
00:00:56,420 --> 00:00:58,310
OK.

23
00:00:58,360 --> 00:01:00,810
I'm adding the same number and times.

24
00:01:00,810 --> 00:01:03,240
So we're using one live plus operator here.

25
00:01:03,270 --> 00:01:10,150
So the solution to the one solution for this problem is to just use a loop and that loop will run end

26
00:01:10,200 --> 00:01:13,990
times and inside the loop we will add Eminem.

27
00:01:14,310 --> 00:01:14,610
OK.

28
00:01:14,640 --> 00:01:19,500
So I think you can solve it very easily with the help of for loop part of a loop.

29
00:01:19,500 --> 00:01:22,320
But now we have to solve it using recursion.

30
00:01:22,440 --> 00:01:22,920
OK.

31
00:01:23,040 --> 00:01:27,480
So with that before loop how you will solve you will keep a variable sum equals zero.

32
00:01:27,480 --> 00:01:30,360
You will run a loop and that group will run.

33
00:01:30,370 --> 00:01:33,630
And times inside the loop what you will do.

34
00:01:33,630 --> 00:01:38,940
You will write something like this simplistic was to him and then the loop will be all whether you will

35
00:01:38,940 --> 00:01:39,930
have done some.

36
00:01:39,960 --> 00:01:41,130
OK.

37
00:01:41,340 --> 00:01:44,220
So with the help of recursion how we can solve this problem.

38
00:01:44,370 --> 00:01:49,190
So we have to calculate M in doing okay.

39
00:01:49,200 --> 00:01:54,840
Let's say the value of M is five and led to the value of minus three.

40
00:01:54,870 --> 00:01:59,310
So our output will be 15 m in the end is 15.

41
00:01:59,340 --> 00:02:00,000
Okay.

42
00:02:00,000 --> 00:02:10,660
So m in doing so can I write M into N like M multiply and minus one bless em.

43
00:02:10,660 --> 00:02:16,470
Can I add I did like this yes obviously we can write it like this.

44
00:02:16,650 --> 00:02:22,500
This isn't a thing but if you multiply inside this is I mean minus M lesson and these two will cancel

45
00:02:22,500 --> 00:02:23,070
out each other.

46
00:02:23,070 --> 00:02:25,210
So it totally M N okay.

47
00:02:25,320 --> 00:02:28,620
And so let's dry it and how we look.

48
00:02:28,650 --> 00:02:36,240
So m in doing so I want to calculate five into three what I want to do here is multiply five with two

49
00:02:36,330 --> 00:02:38,010
and then add plus five.

50
00:02:38,010 --> 00:02:40,670
So the answer will be five into two.

51
00:02:40,710 --> 00:02:42,980
That answer will be fifteen only.

52
00:02:43,020 --> 00:02:47,130
Okay so basically what we're doing here is so five in total.

53
00:02:47,160 --> 00:02:52,200
This simply means five plus five plus five.

54
00:02:52,230 --> 00:02:59,510
So what we will do I will tell the equation to solve this smaller problem and then I will add five.

55
00:03:00,080 --> 00:03:01,110
I will add m.

56
00:03:01,190 --> 00:03:01,460
Okay.

57
00:03:01,490 --> 00:03:07,100
This is m this is M and this is an okay so I'm building myself

58
00:03:09,810 --> 00:03:15,120
let's take one more example let's say the value of M is three and the value of n is five.

59
00:03:15,720 --> 00:03:18,830
Okay so I want to convert them into n.

60
00:03:18,990 --> 00:03:25,420
So basically what we can do M Plus M Plus M How many times and times.

61
00:03:25,470 --> 00:03:25,770
Okay.

62
00:03:28,820 --> 00:03:35,320
So I want to multiply three into five so I will add three five times.

63
00:03:35,390 --> 00:03:40,250
So three plus three plus three plus three plus three.

64
00:03:40,700 --> 00:03:41,130
Okay.

65
00:03:41,210 --> 00:03:45,290
So now what we will do we will use the help of the equation.

66
00:03:45,380 --> 00:03:46,490
What we will use.

67
00:03:46,520 --> 00:03:49,360
So what we will do we will break the problem into smaller problem.

68
00:03:49,370 --> 00:03:53,030
I will tell recursion to solve this part for me.

69
00:03:54,330 --> 00:03:57,530
And that equation will give me the answer and the answer will be.

70
00:03:58,260 --> 00:04:01,030
And then I will add m.

71
00:04:01,080 --> 00:04:01,380
Okay.

72
00:04:01,380 --> 00:04:08,260
So this is M So the equation will give me the answer which is drill and then I will add M so if I have

73
00:04:08,260 --> 00:04:09,570
a function multiply.

74
00:04:10,710 --> 00:04:17,550
So how does multiplatform assembly look like it can take two input as outgoing M and then what I will

75
00:04:17,550 --> 00:04:22,700
call I will call the same function multiply a function for the smaller input.

76
00:04:23,100 --> 00:04:27,400
So I will tell occasion to give me down shut off.

77
00:04:27,420 --> 00:04:31,980
So what it will give me it will give me the onset of M multiply and minus 1.

78
00:04:32,070 --> 00:04:32,370
Okay.

79
00:04:32,370 --> 00:04:35,860
And this is M in two n.

80
00:04:35,970 --> 00:04:38,010
And finally what do we do.

81
00:04:38,100 --> 00:04:44,580
We will add after equation we give me the answer I will add this m okay so this will be our formula

82
00:04:44,610 --> 00:04:48,030
this will we this will be how that equation will look like.

83
00:04:48,150 --> 00:04:52,170
Okay now first let us write the code and then we will died in the code.

84
00:04:52,170 --> 00:04:54,780
Okay so what will be our base case.

85
00:04:54,780 --> 00:05:00,420
So the base case will be very simple you want to calculate M in doing so base case will be the value

86
00:05:00,420 --> 00:05:01,780
of any 0.

87
00:05:01,890 --> 00:05:06,750
Then if you multiply with zero then now good will be Z only okay if you multiply any number with zero

88
00:05:06,750 --> 00:05:08,010
that now it will be zero only.

89
00:05:08,010 --> 00:05:11,810
So this will be our base case if any 0 return 0.

90
00:05:11,910 --> 00:05:12,350
Okay.

91
00:05:12,420 --> 00:05:15,090
Now first let us write the code and then we will drive.

92
00:05:15,210 --> 00:05:15,470
Okay

93
00:05:19,150 --> 00:05:26,920
so that it I will be in digit and let's say the name of the function is multiply what it will take it

94
00:05:26,920 --> 00:05:30,740
will take two integer as argument M and then okay.

95
00:05:30,750 --> 00:05:40,500
And what we have to conclude we have to calculate M in doing we have to calculate M in doing but without

96
00:05:40,500 --> 00:05:43,560
using multiply or pretend without for loop or Y loop.

97
00:05:43,560 --> 00:05:46,430
Okay now it's time for the base case.

98
00:05:46,590 --> 00:05:51,590
So the base case is the smallest problem whose solution we already know save the value of any 0.

99
00:05:51,630 --> 00:05:55,320
So any number multiplied with zero will be zero only.

100
00:05:55,320 --> 00:05:57,560
So I will return 0.

101
00:05:57,650 --> 00:06:03,200
Now it's time for the recursive case what we have to do we have to solve the problem for the smaller

102
00:06:03,200 --> 00:06:04,460
input okay.

103
00:06:04,520 --> 00:06:11,020
And where did this Malone put similar input is led to the value of and this and minus one to small and.

104
00:06:12,830 --> 00:06:17,930
A small answer is you have to I'm calling the same function multiply

105
00:06:20,740 --> 00:06:24,390
and I wanted to conclude M and do n minus one.

106
00:06:24,730 --> 00:06:34,850
Okay so at this line I have done set off M and do and minus 1 and finally our calculation part of our

107
00:06:34,850 --> 00:06:36,980
calculation part is very simple.

108
00:06:37,980 --> 00:06:47,080
What we have to do I will return this small answer bless em and medicine.

109
00:06:47,620 --> 00:06:57,360
Okay now let's call this function so let's call this function and let us give the value of a man an

110
00:06:58,670 --> 00:07:03,680
so multiply and led to the values that three and 5.

111
00:07:04,320 --> 00:07:06,510
Okay.

112
00:07:06,700 --> 00:07:09,830
Now if we learn this code our output will reach 15.

113
00:07:09,890 --> 00:07:10,380
Okay.

114
00:07:11,770 --> 00:07:18,680
So let's send the file salad out for this coming out 215 basic level code is working fine.

115
00:07:18,680 --> 00:07:22,970
Okay so this typing mistake here.

116
00:07:25,110 --> 00:07:27,810
Okay now let's try to understand how output is coming out.

117
00:07:27,810 --> 00:07:32,590
215 Okay so the values are 3 and 5.

118
00:07:32,600 --> 00:07:32,900
Okay.

119
00:07:32,930 --> 00:07:35,280
So we have three and we have five.

120
00:07:35,300 --> 00:07:37,210
So these are the values of him and then.

121
00:07:37,280 --> 00:07:37,820
Okay.

122
00:07:37,910 --> 00:07:40,570
So 5 not articles 2 0.

123
00:07:40,610 --> 00:07:44,040
So basically this function will wait at line number 10.

124
00:07:44,060 --> 00:07:49,110
And I call the function for three comma food again.

125
00:07:49,380 --> 00:07:53,560
This will wait at line number 10 and I will call for true commentary.

126
00:07:53,710 --> 00:08:01,930
Similarly I wouldn't call for a on my 2 then I will call for three call my 1 and then I will call for

127
00:08:01,930 --> 00:08:06,620
three comma zero so the value of any zero redundancy two.

128
00:08:06,650 --> 00:08:07,120
Okay.

129
00:08:07,220 --> 00:08:09,290
So basically this will be done zero.

130
00:08:09,620 --> 00:08:11,600
So zero will be stored in this small answer.

131
00:08:11,600 --> 00:08:13,820
So small answer becomes zero.

132
00:08:13,820 --> 00:08:14,160
Okay.

133
00:08:14,200 --> 00:08:17,900
My lines it become zero now I am returning a small answer.

134
00:08:17,900 --> 00:08:18,660
Bless em.

135
00:08:18,680 --> 00:08:20,570
What is the value of m m value of a mystery.

136
00:08:21,170 --> 00:08:28,450
Okay so zero plus 3 it will be three so that's my leave small answer.

137
00:08:28,450 --> 00:08:35,140
So this is small answer then I am returning small answer plus M and the value of a mystery only so three

138
00:08:35,140 --> 00:08:43,830
plus three which is six so six is small answer so six plus three which is nine.

139
00:08:43,990 --> 00:08:49,780
Okay so small answer becomes nine then nine plus three basically twelve.

140
00:08:49,820 --> 00:08:55,250
So small answer is Twin and then twelve plus three which is fifteen.

141
00:08:55,250 --> 00:08:55,540
Okay.

142
00:08:55,550 --> 00:08:57,130
So fifteen is our answer.

143
00:08:57,800 --> 00:08:58,250
Okay.

144
00:08:58,340 --> 00:09:00,760
So that's how that equation is working.

145
00:09:00,800 --> 00:09:01,250
Okay.

146
00:09:01,400 --> 00:09:03,780
So but you do not have to take all of this.

147
00:09:03,800 --> 00:09:04,390
Okay.

148
00:09:04,550 --> 00:09:06,470
We will not think all of this.

149
00:09:06,590 --> 00:09:11,670
What do we think we will think like first right the base case very simple.

150
00:09:11,960 --> 00:09:14,960
Then write the recursive case we will.

151
00:09:14,960 --> 00:09:18,000
We are calculating M2 the power in minus one you have to assume.

152
00:09:18,020 --> 00:09:18,580
Okay.

153
00:09:18,800 --> 00:09:20,480
You add line number 10.

154
00:09:20,630 --> 00:09:25,590
What we are trying to do here is we are assuming that this multiplier function looks okay.

155
00:09:25,700 --> 00:09:31,100
This multiplier function if it if you will give 2 input as argument it will give me m in 2 and minus

156
00:09:31,100 --> 00:09:31,380
1.

157
00:09:31,610 --> 00:09:31,850
Okay.

158
00:09:31,850 --> 00:09:33,760
You have to assume this okay.

159
00:09:33,770 --> 00:09:39,250
You have to assume that this function will work since this function is working it will give me the small

160
00:09:39,250 --> 00:09:45,310
lines so I will add plus M to get to get our prop to get down to what the bigger problem.

161
00:09:45,600 --> 00:09:45,900
Okay.

162
00:09:45,900 --> 00:09:47,610
And then we add turning our answer.

163
00:09:48,030 --> 00:09:52,270
Okay so first write the code then think about the diagram okay.

164
00:09:52,420 --> 00:09:56,480
First write the code then thing go to the diagram to I hope this problem is cleared.

165
00:09:56,580 --> 00:09:58,060
If you have any doubt you can ask me.

166
00:09:58,080 --> 00:09:59,290
Okay thank you.
