1
00:00:01,370 --> 00:00:02,969
Hello, everyone, welcome to this session.

2
00:00:02,990 --> 00:00:07,790
So in this session, what we will do so we will try to solve one more problem with the help of commission.

3
00:00:08,060 --> 00:00:10,210
So the name of the problem is the numbers.

4
00:00:10,970 --> 00:00:13,790
OK, so we will record this problem.

5
00:00:13,880 --> 00:00:15,920
We will solve this problem with the help of the commission.

6
00:00:16,129 --> 00:00:22,120
So what these problems suggest, so if the value of these five, what would I have to do?

7
00:00:22,310 --> 00:00:24,420
So I have to print the numbers from one to end.

8
00:00:24,650 --> 00:00:29,360
So if the value of minus five, I will print the number one, two, three, four, five.

9
00:00:29,480 --> 00:00:32,450
If the value of and three, I will print the numbers.

10
00:00:32,450 --> 00:00:33,650
One, two, three.

11
00:00:33,870 --> 00:00:39,980
OK, so what I have to do, I have to write a function print and and this print and function.

12
00:00:39,980 --> 00:00:43,690
What it will do, it will print the number, it will start printing from one billion.

13
00:00:44,100 --> 00:00:46,640
OK, so this is the work of this function.

14
00:00:46,640 --> 00:00:50,930
We can solve this problem very easily using default all the way, but we have to solve this problem

15
00:00:50,930 --> 00:00:51,170
using.

16
00:00:52,160 --> 00:00:57,260
So using irrigation, what I have to do if I want to solve the problem for and then I have to solve

17
00:00:57,260 --> 00:00:58,970
the problem for the smaller end.

18
00:00:59,170 --> 00:01:06,530
OK, so what this printing function will do, so this printing function, it will print the number from

19
00:01:06,530 --> 00:01:07,200
one to end.

20
00:01:07,250 --> 00:01:11,510
OK, so this printing function, it will print the numbers from one, two and.

21
00:01:12,680 --> 00:01:14,210
So can I write like this?

22
00:01:15,440 --> 00:01:23,090
So what this print and minus one function will do so print and function, its job is to print the numbers

23
00:01:23,420 --> 00:01:25,460
starting from one then.

24
00:01:26,440 --> 00:01:33,070
What this sprint and minus one will do, so it will start printing the number from one bill and minus

25
00:01:33,070 --> 00:01:33,290
one.

26
00:01:33,580 --> 00:01:36,070
OK, and this is our goal.

27
00:01:37,490 --> 00:01:43,670
And this, this and this will be put off and minus one function, then after printing, then minus one

28
00:01:44,060 --> 00:01:49,600
we will print and OK after printing and minus one we will print another term.

29
00:01:49,790 --> 00:01:52,200
So unless we also get printed.

30
00:01:52,220 --> 00:01:53,750
So these two will become equal.

31
00:01:54,830 --> 00:01:55,200
OK.

32
00:01:55,220 --> 00:01:56,780
So this will be our recursive case.

33
00:01:58,300 --> 00:01:59,140
Simple enough.

34
00:01:59,650 --> 00:02:02,320
OK, so let's write the code for this.

35
00:02:05,980 --> 00:02:11,860
So first of all, word of the return type return will be void because I'm not I'm not returning anything.

36
00:02:11,860 --> 00:02:16,210
I'm basically printing, OK, so I have to print what it will take.

37
00:02:16,210 --> 00:02:18,000
It will take on this argument.

38
00:02:18,640 --> 00:02:21,310
OK, so first of all, what will be the best case?

39
00:02:23,990 --> 00:02:29,600
Whatever the best case, so basically the smallest the smallest problem whose solution we already know.

40
00:02:30,650 --> 00:02:35,900
So the smallest problem will be if the value of any zero, so if the value of any zero, what I have

41
00:02:35,900 --> 00:02:42,110
to do, what I have to print, I do not have to print anything, OK, if the value of Aniceto do not

42
00:02:42,110 --> 00:02:42,810
print anything.

43
00:02:43,190 --> 00:02:47,230
So this will be our best case because I have to start printing from one you can see here.

44
00:02:48,800 --> 00:02:50,990
We have to start printing from one.

45
00:02:50,990 --> 00:02:53,940
If the value of an is zero, we will not print painting.

46
00:02:54,020 --> 00:02:55,970
OK, I have to start printing from one.

47
00:02:56,150 --> 00:02:58,370
You can also write the best case for an equals one.

48
00:02:58,370 --> 00:03:01,430
Also, if the value of this one, then print one.

49
00:03:02,110 --> 00:03:09,680
OK, so as you wish you can as a wish, you can modify the Good Samaritan type word.

50
00:03:10,280 --> 00:03:12,050
Hence I am not understanding anything.

51
00:03:12,080 --> 00:03:12,420
OK.

52
00:03:13,070 --> 00:03:16,870
So if the value of any zero then do not print anything otherwise.

53
00:03:17,660 --> 00:03:19,010
First, what do you have to do.

54
00:03:19,080 --> 00:03:20,060
Recursive case.

55
00:03:20,990 --> 00:03:22,400
So recursive case will be.

56
00:03:24,260 --> 00:03:31,130
So dysfunction, brain function, it brings the number from one to and now I'm calling this brain function

57
00:03:31,820 --> 00:03:33,650
four and minus one, what will happen?

58
00:03:34,890 --> 00:03:37,380
Our numbers will get brain dead from one twin.

59
00:03:37,400 --> 00:03:39,010
So what will the output of this line?

60
00:03:39,890 --> 00:03:42,860
This line will print the numbers starting from one.

61
00:03:44,460 --> 00:03:45,240
And minus one.

62
00:03:46,450 --> 00:03:52,050
OK, so this is the this is our output in line number 11.

63
00:03:52,100 --> 00:03:54,230
OK, so this is our output line number 11.

64
00:03:55,700 --> 00:03:57,360
Now our third thing.

65
00:03:57,730 --> 00:04:01,880
So the calculation part, what I have to do, I have to print and it's done.

66
00:04:02,420 --> 00:04:05,230
OK, now let's print.

67
00:04:07,320 --> 00:04:09,660
OK, so this is our output.

68
00:04:10,610 --> 00:04:17,480
OK, so this print function, what it what it does is it brings the number from one twin print, then

69
00:04:17,490 --> 00:04:20,010
minus one, it will print the number from one to ten, minus one.

70
00:04:20,010 --> 00:04:21,779
And then I am printing the net number.

71
00:04:22,620 --> 00:04:26,760
OK, now let's call this function, let's call this print function.

72
00:04:28,020 --> 00:04:29,140
Four to five.

73
00:04:29,290 --> 00:04:29,580
OK.

74
00:04:30,940 --> 00:04:36,070
Now, let's than another file, OK, so dysfunctional, not returning anything, so I have to call this

75
00:04:36,070 --> 00:04:40,780
function, I cannot write you out, OK, because dysfunctional, not running anything.

76
00:04:41,170 --> 00:04:42,250
Now let's an our file.

77
00:04:45,320 --> 00:04:47,670
So this is our output one, two, three, four and five.

78
00:04:47,990 --> 00:04:49,640
OK, so our goal is working fine.

79
00:04:49,880 --> 00:04:52,990
Now after writing the code, what we have to do, we have to make their diagram.

80
00:04:53,120 --> 00:04:55,640
We have to tighten our code so we can understand it better.

81
00:04:56,120 --> 00:04:59,310
OK, so Brent five, the value of and is five.

82
00:04:59,330 --> 00:05:01,610
OK, so this is five.

83
00:05:02,220 --> 00:05:03,650
So I am writing the output here.

84
00:05:03,650 --> 00:05:04,730
I will write the output here.

85
00:05:04,740 --> 00:05:07,880
OK, so five will call on four.

86
00:05:10,480 --> 00:05:11,860
Four will call on three.

87
00:05:12,730 --> 00:05:18,080
Three will call on two, two will call on when, one will call on zero.

88
00:05:18,430 --> 00:05:21,460
So if the value of any zero, what I'm doing is done.

89
00:05:21,820 --> 00:05:22,920
So I will come here.

90
00:05:22,920 --> 00:05:23,360
We're done.

91
00:05:23,830 --> 00:05:29,020
OK, so one was waiting at line number 11 when was waiting in line number 11.

92
00:05:29,050 --> 00:05:35,680
Now I will reach your line, but I didn't see out and OK, so at this line what will happen to out end.

93
00:05:35,680 --> 00:05:36,850
So when will get printed.

94
00:05:37,510 --> 00:05:40,550
Now you can write a written statement here also.

95
00:05:40,570 --> 00:05:41,920
OK, they're done the statement.

96
00:05:41,920 --> 00:05:42,550
This is optional.

97
00:05:42,560 --> 00:05:43,290
So what will happen.

98
00:05:43,300 --> 00:05:44,020
I will come here.

99
00:05:44,970 --> 00:05:52,470
OK, so the value of this to so, too, was also waiting at line number 11, then CO2, so too will

100
00:05:52,470 --> 00:05:53,040
get printed.

101
00:05:53,050 --> 00:05:56,940
So one gets printed first, then two printed, then are done.

102
00:05:57,310 --> 00:06:00,370
I will write the line written, I will write the statement written.

103
00:06:00,390 --> 00:06:01,320
But this is optional.

104
00:06:01,330 --> 00:06:03,720
Okay, because the cord and red line number 15.

105
00:06:03,930 --> 00:06:05,550
So writing written is optional here.

106
00:06:06,500 --> 00:06:09,230
So the value of industry now will get better.

107
00:06:09,260 --> 00:06:14,390
So return the value of this for for will get printed the value of faintness five, five years, get

108
00:06:14,390 --> 00:06:18,080
printed and then finally return, I will reach the mean and then return.

109
00:06:18,320 --> 00:06:20,810
Our program will be over and this will be our output.

110
00:06:21,380 --> 00:06:25,370
OK, so you might so you might have confusion.

111
00:06:25,400 --> 00:06:26,380
So I am returning.

112
00:06:27,050 --> 00:06:28,680
I am writing right down here, ok.

113
00:06:28,820 --> 00:06:31,400
It will not affect our goal of course will still work fine.

114
00:06:34,000 --> 00:06:36,490
So our output is still one, two, three, four, five.

115
00:06:37,120 --> 00:06:40,200
OK, so our goal is working fine now.

116
00:06:40,210 --> 00:06:40,780
One more thing.

117
00:06:43,130 --> 00:06:43,850
So here.

118
00:06:44,890 --> 00:06:46,810
I have been the numbers in ascending order.

119
00:06:48,140 --> 00:06:50,600
I am printing the numbers in ascending order one, two.

120
00:06:50,680 --> 00:06:55,610
Now, whatever, I want to print the number in descending order, for example, of the value of and

121
00:06:55,610 --> 00:07:00,260
his wife, I want to print five, four, three, two and one.

122
00:07:00,520 --> 00:07:02,750
OK, this is how I want to print the number.

123
00:07:02,770 --> 00:07:05,090
Basically, I want to print the number in descending order.

124
00:07:05,780 --> 00:07:13,250
OK, so what we will do let's say I am writing print to function, so print to what it will take, it

125
00:07:13,250 --> 00:07:18,910
will take and as input and its work is what it will do, it will print the numbers in descending order.

126
00:07:19,130 --> 00:07:21,180
Five, four, three, two and one.

127
00:07:21,970 --> 00:07:29,270
OK, so first of all, what I will do, I will print and OK, because the value of it is five five is

128
00:07:29,270 --> 00:07:30,210
getting printed first.

129
00:07:30,470 --> 00:07:36,860
So first of all, I will print that number in and then I will call the function and minus one.

130
00:07:37,510 --> 00:07:38,150
So what.

131
00:07:38,150 --> 00:07:44,390
And minus one will do so and minus one will start bending the numbers from and minus one then and minus

132
00:07:44,390 --> 00:07:45,570
two L1.

133
00:07:46,310 --> 00:07:52,730
OK, and first of all and we'll get printer and our work was also the same.

134
00:07:53,180 --> 00:07:55,160
We have to print the numbers in descending order.

135
00:07:55,670 --> 00:08:02,150
OK, so first I have to print N and then I will call, I will call the same function here.

136
00:08:02,540 --> 00:08:03,820
It will be a portrait of this.

137
00:08:04,070 --> 00:08:11,060
So first I was calling and minus one and then I was printing and but here first I will print N and then

138
00:08:11,060 --> 00:08:12,470
I will call and minus one.

139
00:08:12,680 --> 00:08:16,340
OK, so basically descending order will be the opposite of the ascending order.

140
00:08:16,890 --> 00:08:22,040
OK, so what I will do, let's write print to function.

141
00:08:22,370 --> 00:08:23,750
Let us copy this code.

142
00:08:26,700 --> 00:08:32,870
So this is Sprink to function now what I have to do, I have to just change the order of these two lines.

143
00:08:33,179 --> 00:08:35,190
So first, I will print an.

144
00:09:01,170 --> 00:09:05,450
OK, so this will be our bench to function, so to function, what it does is.

145
00:09:05,490 --> 00:09:07,180
So this is our best case now.

146
00:09:07,260 --> 00:09:11,550
First I will print and and then I will call and minus one.

147
00:09:11,700 --> 00:09:15,390
So sorry, this will be print to OK, print to function.

148
00:09:15,870 --> 00:09:17,110
So what this function will do.

149
00:09:17,130 --> 00:09:20,490
It will start printing the numbers from and minus one.

150
00:09:22,790 --> 00:09:29,770
Well, one, OK, so this will be the output of this line, but before the output of this line, I am

151
00:09:29,770 --> 00:09:34,270
printing and OK, now let's call print to function.

152
00:09:34,450 --> 00:09:37,660
So I'm calling print to function and I'm giving fifers input.

153
00:09:37,900 --> 00:09:40,510
So our output will be five, four, three, two and one.

154
00:09:40,570 --> 00:09:43,690
OK, so let's another good.

155
00:09:46,530 --> 00:09:51,120
So I put five, four, three, two and one now after writing the code, what we have to do, we have

156
00:09:51,120 --> 00:09:54,690
to have a goal so that we can understand what is going on here.

157
00:09:54,990 --> 00:09:57,170
OK, so the value of N is five.

158
00:09:57,510 --> 00:10:01,670
OK, so this is five and I will write my output here.

159
00:10:01,740 --> 00:10:09,630
OK, so five is not close to zero C out and so five will get printed and then I am calling print to

160
00:10:09,630 --> 00:10:11,280
function with the value and minus one.

161
00:10:11,770 --> 00:10:16,080
OK, so the value of Anisfield four is not close to zero zero then.

162
00:10:16,080 --> 00:10:18,030
So four will get printed then.

163
00:10:18,660 --> 00:10:20,220
We are calling with a smaller function.

164
00:10:20,580 --> 00:10:22,590
OK, I will call on three.

165
00:10:23,510 --> 00:10:28,640
Then they will get printed, I will call and one I will call and do two is not close to zero, then

166
00:10:28,640 --> 00:10:29,540
I will bring it to.

167
00:10:30,670 --> 00:10:32,120
Then will call on one.

168
00:10:32,890 --> 00:10:40,600
So one is not close to zero, so I will bring one, then I will call on zero zero zero equals zero.

169
00:10:40,630 --> 00:10:42,210
Then I what I will do, I will return.

170
00:10:42,580 --> 00:10:43,520
So I will return.

171
00:10:43,780 --> 00:10:46,680
So when was waiting at line number 26.

172
00:10:46,780 --> 00:10:53,890
OK, this one was waiting at line number 26 then written, so written there was also waiting at line

173
00:10:53,890 --> 00:10:55,980
number 26 and then return.

174
00:10:56,320 --> 00:11:02,470
So I will return three was waiting in line number 26 then it will return four was also waiting.

175
00:11:02,470 --> 00:11:08,910
I remember 26 then written and then five was also waiting at line number twenty six and then return.

176
00:11:09,340 --> 00:11:12,140
So it had done so and this is our output.

177
00:11:12,160 --> 00:11:13,300
Five, four, three, two, one.

178
00:11:13,600 --> 00:11:17,440
OK, so I hope you understand the code, how it is working.

179
00:11:18,370 --> 00:11:22,660
OK, so writing this return but writing this written statement is optional here.

180
00:11:22,660 --> 00:11:24,250
If you want you can remove it also.

181
00:11:24,310 --> 00:11:33,310
OK, for example let's remove this line and then also have a code of a code will work because the function

182
00:11:33,310 --> 00:11:38,860
ends here and there, the function and that automatically means that are done OK with the void you have

183
00:11:38,860 --> 00:11:39,790
option to return.

184
00:11:40,660 --> 00:11:44,140
This is optional here, but writing return here is mandatory.

185
00:11:44,170 --> 00:11:47,910
OK, writing the return statement inside the IF is mandatory.

186
00:11:48,520 --> 00:11:51,760
OK, so this return is compulsory.

187
00:11:53,550 --> 00:11:58,680
Otherwise, what will happen if I will not write the written statement, what will happen, I will commit

188
00:11:58,680 --> 00:12:00,610
line number 22, which is wrong.

189
00:12:00,910 --> 00:12:04,200
OK, so writing written is mandatory here.

190
00:12:06,840 --> 00:12:09,030
But this return is optional.

191
00:12:09,110 --> 00:12:09,450
OK?

192
00:12:11,840 --> 00:12:13,780
And also, this return is optional.

193
00:12:16,130 --> 00:12:22,400
Now, I doubt this are done, but now if we run our program, our program will still work fine out probably

194
00:12:22,550 --> 00:12:23,690
five, four, three, two, one, one.

195
00:12:23,780 --> 00:12:27,520
OK, so I hope you understand why this is mandatory.

196
00:12:27,540 --> 00:12:27,880
I am.

197
00:12:28,250 --> 00:12:29,160
Let's try to.

198
00:12:29,690 --> 00:12:32,360
So it was a value of industry.

199
00:12:32,390 --> 00:12:35,380
Let's say I am calling brain to function for the value of industry.

200
00:12:35,660 --> 00:12:36,920
So three, what will happen.

201
00:12:36,920 --> 00:12:42,490
Three will call on, two do will call and one no one will call on zero zero zero equals zero.

202
00:12:42,860 --> 00:12:46,030
So if you will not read the written statement, what will happen.

203
00:12:46,280 --> 00:12:47,560
So zero will come here.

204
00:12:48,320 --> 00:12:50,060
Zero zero zero zero will get.

205
00:12:50,060 --> 00:12:50,980
This is our output.

206
00:12:51,320 --> 00:12:52,130
So what will happen.

207
00:12:52,130 --> 00:12:53,210
Zero will get printed.

208
00:12:54,440 --> 00:12:56,360
OK, so this is Brent to function.

209
00:12:56,390 --> 00:12:59,220
So what will happen to our output is three to one.

210
00:12:59,480 --> 00:13:00,190
Now what will happen?

211
00:13:00,210 --> 00:13:02,880
The value of N is zero, so zero zero.

212
00:13:02,900 --> 00:13:05,630
But if the written statement is not here, then what will happen?

213
00:13:05,630 --> 00:13:07,160
I will come line number 23.

214
00:13:07,430 --> 00:13:08,750
So zero will get printed.

215
00:13:09,380 --> 00:13:12,980
Then what I will do, I will call on Ben to function and mightiness.

216
00:13:12,980 --> 00:13:18,950
And so it will call on minus one, then minus one will get printed, it will call on minus two, it

217
00:13:18,950 --> 00:13:20,600
will call on minus three and so on.

218
00:13:20,600 --> 00:13:22,880
Basically infinite loop problem will be there.

219
00:13:23,690 --> 00:13:25,680
OK, so infinite loop problem will be there.

220
00:13:25,700 --> 00:13:27,740
That's why this return is mandatory here.

221
00:13:27,740 --> 00:13:29,290
If this are done, is there what will happen.

222
00:13:29,300 --> 00:13:30,470
I will return from zero.

223
00:13:30,860 --> 00:13:32,900
OK, and this will not happen.

224
00:13:33,730 --> 00:13:38,450
OK, so this return is mandatory and there is this written is optional.

225
00:13:38,630 --> 00:13:39,020
OK.

226
00:13:42,200 --> 00:13:45,200
And similarly for this one, also for brain function.

227
00:13:45,480 --> 00:13:48,140
OK, what will happen?

228
00:13:48,440 --> 00:13:50,150
Suppose the value of industry.

229
00:13:51,950 --> 00:13:56,480
Now, what will happen and is not close to zero, this this is our output.

230
00:13:56,850 --> 00:13:58,450
I'm calling on smaller part.

231
00:13:58,460 --> 00:14:02,950
So to do will call on when one will call on zero.

232
00:14:03,380 --> 00:14:05,010
OK, so zero zero.

233
00:14:05,270 --> 00:14:07,330
So if the written statement is there, what will happen?

234
00:14:07,520 --> 00:14:10,680
I will come out one and then one will get printed.

235
00:14:11,600 --> 00:14:15,920
But if this written statement is not there, what will happen?

236
00:14:16,850 --> 00:14:21,740
What will happen when I call on zero zero zero but the written statement is not there, then I will

237
00:14:21,740 --> 00:14:23,180
come here a headline number 11.

238
00:14:23,180 --> 00:14:26,720
I will call minus one, then minus and will call on minus two.

239
00:14:26,720 --> 00:14:28,340
Minus two will call on minus three.

240
00:14:28,340 --> 00:14:31,030
Ansun, basically infinite loop problem will be there.

241
00:14:31,700 --> 00:14:33,580
That's why I return is mandatory here.

242
00:14:33,620 --> 00:14:37,550
OK, inside the base case returns statement is mandatory.

243
00:14:38,090 --> 00:14:39,290
OK, remember this thing.

244
00:14:40,460 --> 00:14:41,930
So I hope you understood the school.

245
00:14:42,150 --> 00:14:43,340
OK, thank you.

