1
00:00:01,430 --> 00:00:03,050
Hello everyone welcome to the session.

2
00:00:03,050 --> 00:00:08,070
So in this session what we will do so we will try to solve one more problem with the help of the occasion.

3
00:00:08,120 --> 00:00:10,980
So the name of the problem is printed numbers.

4
00:00:11,120 --> 00:00:13,850
Okay so we will cause this problem.

5
00:00:13,940 --> 00:00:16,190
We will solve this problem with the help of the equation.

6
00:00:16,190 --> 00:00:17,960
So what this problem suggests.

7
00:00:18,320 --> 00:00:20,950
So if the value of minus five.

8
00:00:21,080 --> 00:00:22,160
What would I have to do.

9
00:00:22,400 --> 00:00:27,260
So I have to print the numbers from 1 2 n so if the value of find his wife I will print the number 1

10
00:00:27,450 --> 00:00:29,510
2 3 4 5.

11
00:00:29,600 --> 00:00:33,920
If the value of and is three I will print the numbers one two three.

12
00:00:33,930 --> 00:00:38,010
Okay so what I have to do I have to write a function print.

13
00:00:38,120 --> 00:00:41,780
And and this print and function what it will do it will print the number.

14
00:00:41,780 --> 00:00:43,720
It will start printing from 1 Bill.

15
00:00:44,200 --> 00:00:44,550
Okay.

16
00:00:45,110 --> 00:00:46,630
So this is the bulk of dysfunction.

17
00:00:46,640 --> 00:00:50,630
We can solve this problem very easily using the for loop all the while loop but we have to solve this

18
00:00:50,630 --> 00:00:51,710
problem using a regression.

19
00:00:52,220 --> 00:00:57,350
So using regression what I have to do if I want to solve the problem for n then i have to solve the

20
00:00:57,350 --> 00:00:59,200
problem for the smaller end.

21
00:00:59,240 --> 00:00:59,720
Okay.

22
00:00:59,810 --> 00:01:03,160
So what this print n function will do.

23
00:01:03,290 --> 00:01:07,220
So this print n function it will print the number from 1 2.

24
00:01:07,270 --> 00:01:07,720
Okay.

25
00:01:07,730 --> 00:01:14,240
So this print then function it will print the numbers from 1 2 and so can I write like this.

26
00:01:15,530 --> 00:01:23,120
So what this print and minus one function will do so print and function its job is to print the numbers

27
00:01:23,480 --> 00:01:28,740
starting from one deal and what this print and minus one will do.

28
00:01:28,840 --> 00:01:33,670
So it will start printing the number from one bill and minus one.

29
00:01:33,700 --> 00:01:34,310
Okay.

30
00:01:34,330 --> 00:01:42,080
And this is our goal and this this is and this will be the output of and minus one function.

31
00:01:42,080 --> 00:01:45,150
Then after printing that and minus one we will print n.

32
00:01:46,020 --> 00:01:46,560
Okay.

33
00:01:46,670 --> 00:01:50,320
After printing and minus one we will print and that's done so.

34
00:01:50,540 --> 00:01:52,270
And this time will also get printed.

35
00:01:52,280 --> 00:01:54,810
So these two will become equal.

36
00:01:54,920 --> 00:01:55,190
Okay.

37
00:01:55,220 --> 00:01:59,690
So this will be our recursive case simple enough.

38
00:01:59,710 --> 00:02:00,020
Okay.

39
00:02:00,520 --> 00:02:06,020
So let's write the code for this.

40
00:02:06,070 --> 00:02:11,470
So first of all you're too little return type return type will be void because I'm not I'm not returning

41
00:02:11,470 --> 00:02:13,050
anything I'm basically printing.

42
00:02:13,100 --> 00:02:18,650
Okay so I have to print what it will take it will take I integer s argument.

43
00:02:18,780 --> 00:02:19,020
Okay.

44
00:02:19,030 --> 00:02:27,710
So first of all what will be the base case what do with the base case so base case is the smallest smallest

45
00:02:27,710 --> 00:02:33,530
problem whose solution we already know so the smallest problem will be if the value of any 0.

46
00:02:34,400 --> 00:02:39,860
So if the value of an Israel would have to do what I have to print I do not have to print anything.

47
00:02:39,860 --> 00:02:40,400
Okay.

48
00:02:40,460 --> 00:02:43,250
If the value of an Israel do not print anything.

49
00:02:43,250 --> 00:02:46,380
So this would be our base case because I have to start printing from 1.

50
00:02:46,430 --> 00:02:50,980
You can see here we have to start printing from 1.

51
00:02:50,990 --> 00:02:53,920
If the value of and is 0 we will not print anything.

52
00:02:54,050 --> 00:02:54,580
Okay.

53
00:02:54,650 --> 00:02:56,130
You have to start printing from 1.

54
00:02:56,210 --> 00:03:02,110
You can also write the base case for any question also if the value of land is 1 then print 1.

55
00:03:02,180 --> 00:03:02,660
Okay.

56
00:03:03,080 --> 00:03:08,210
So as you wish you can as you wish you can modify the code.

57
00:03:08,270 --> 00:03:08,540
Okay.

58
00:03:08,540 --> 00:03:12,140
So the return type is void hence I am not understanding anything.

59
00:03:12,140 --> 00:03:13,000
Okay.

60
00:03:13,160 --> 00:03:20,090
So if the value of any 0 then do not print anything otherwise first what we have to do recursive case

61
00:03:21,080 --> 00:03:27,870
so recursive case will be so this function print function it prints the number from 1 2.

62
00:03:27,880 --> 00:03:32,920
And now I'm calling this print function for and minus 1.

63
00:03:32,930 --> 00:03:37,430
What will happen our numbers will get printed from 1 to 1.

64
00:03:37,460 --> 00:03:46,630
So what will output of this line this line will print the numbers starting from 1 bill and minus 1.

65
00:03:46,660 --> 00:03:52,150
Okay so this is the this is our output a line number eleven.

66
00:03:52,150 --> 00:03:52,410
Okay.

67
00:03:52,420 --> 00:03:55,590
So this is our output to line number eleven.

68
00:03:55,780 --> 00:03:57,750
Now our third thing.

69
00:03:57,790 --> 00:04:01,930
So the calculation part what I have to do I have to print and it's dumb.

70
00:04:02,480 --> 00:04:04,230
Okay.

71
00:04:04,300 --> 00:04:10,680
Now let's print Okay so this is our output.

72
00:04:10,680 --> 00:04:14,010
Okay so this print function what is it.

73
00:04:14,100 --> 00:04:18,060
What it does is it prints the number from 1 2 in print and minus 1.

74
00:04:18,050 --> 00:04:24,180
It will print the number from 1 to N minus 1 and then I am printing the anything but okay now let's

75
00:04:24,180 --> 00:04:29,230
call this function let's call this print function for let's five.

76
00:04:29,270 --> 00:04:29,530
Okay.

77
00:04:31,030 --> 00:04:32,130
Now let's send in our file.

78
00:04:32,500 --> 00:04:37,230
Okay so this function is not returning anything so I have to call this function.

79
00:04:37,360 --> 00:04:41,220
I cannot write you out okay because this function audit ending anything.

80
00:04:41,260 --> 00:04:42,220
Now let's send our file

81
00:04:45,380 --> 00:04:47,860
so the -- that output 1 2 3 4 and 5.

82
00:04:48,050 --> 00:04:53,090
Okay so our code is working fine now after writing the code what we have to do we have to make the diagram.

83
00:04:53,210 --> 00:04:55,890
We have to brighten our code so we can understand it better.

84
00:04:56,270 --> 00:04:57,950
Okay so print 5.

85
00:04:57,980 --> 00:04:59,300
The value of an is 5.

86
00:04:59,390 --> 00:05:01,610
Okay so this is 5.

87
00:05:02,300 --> 00:05:03,670
So I am writing the output here.

88
00:05:03,680 --> 00:05:04,730
I will write output here.

89
00:05:04,760 --> 00:05:18,490
Okay so 5 will call on 4 4 will call on 3 3 will call on 2 2 will call on 1 1 will call on 0.

90
00:05:18,490 --> 00:05:20,270
So if the value of any 0.

91
00:05:20,290 --> 00:05:21,000
What I'm doing.

92
00:05:21,020 --> 00:05:21,480
Return.

93
00:05:21,880 --> 00:05:22,940
So I will come here.

94
00:05:22,960 --> 00:05:24,000
We're done.

95
00:05:24,000 --> 00:05:29,080
Okay so when was waiting at line number eleven when was waiting at line number eleven.

96
00:05:29,080 --> 00:05:35,890
Now I will reach your line number 13 C out and okay so add at this line what will happen C out and so

97
00:05:35,890 --> 00:05:37,250
when we'll get printed.

98
00:05:37,570 --> 00:05:40,570
Now you can write a written statement here also.

99
00:05:40,600 --> 00:05:41,090
Okay.

100
00:05:41,140 --> 00:05:42,550
The return statement this is optional.

101
00:05:42,550 --> 00:05:43,300
So what will happen.

102
00:05:43,300 --> 00:05:45,380
I will come here okay.

103
00:05:45,420 --> 00:05:51,710
So the value of this to so do was also waiting at line number eleven then CO2.

104
00:05:51,720 --> 00:05:56,130
So two will get printed so one get printed first then 2 printed.

105
00:05:56,130 --> 00:05:57,380
Then you're done.

106
00:05:57,420 --> 00:05:58,680
I will write the line you're done.

107
00:05:58,740 --> 00:06:01,300
I will write the statement then but this is optional.

108
00:06:01,350 --> 00:06:03,980
Okay because the code ends at line number 15.

109
00:06:03,990 --> 00:06:05,690
So I think Red done is optional here.

110
00:06:06,560 --> 00:06:09,260
So the value of industry now tables get printed.

111
00:06:09,290 --> 00:06:12,590
So write down the value of minus 4 4 will get printed.

112
00:06:12,770 --> 00:06:18,010
The value of minus 5 5 will get printed and then find literate and I will reach the mean and then return

113
00:06:18,090 --> 00:06:19,490
the other program will be all what.

114
00:06:19,550 --> 00:06:20,820
And this will be our output.

115
00:06:21,470 --> 00:06:23,790
Okay so you might.

116
00:06:24,050 --> 00:06:25,360
So you might have confusion.

117
00:06:25,370 --> 00:06:26,770
So I am returning.

118
00:06:27,170 --> 00:06:28,370
I am writing return here.

119
00:06:28,370 --> 00:06:28,900
Okay.

120
00:06:28,940 --> 00:06:30,090
It will an artifact Delacorte.

121
00:06:30,110 --> 00:06:31,500
I've got will still work fine.

122
00:06:34,030 --> 00:06:37,050
So our output is still one two three four five.

123
00:06:37,150 --> 00:06:37,830
Okay.

124
00:06:37,970 --> 00:06:40,000
Java code is working fine.

125
00:06:40,000 --> 00:06:48,080
Now one more thing so here I abandon them both in ascending order.

126
00:06:48,260 --> 00:06:52,880
I am printing the numbers in descending order 1 2 and now what if I print I want to print the number

127
00:06:52,880 --> 00:06:53,890
in descending order.

128
00:06:54,050 --> 00:07:00,600
For example if the value of and is 5 I want to print 5 4 3 2 and when.

129
00:07:00,610 --> 00:07:02,750
Okay this is how I want to print the number.

130
00:07:02,750 --> 00:07:05,090
Basically I want to print the number in descending order.

131
00:07:05,900 --> 00:07:13,430
Okay so what we will do let's say I am writing print to function so print to what it will take it will

132
00:07:13,430 --> 00:07:19,490
take and as input and its work as to what it will do it will print the numbers in descending order five

133
00:07:19,490 --> 00:07:21,280
four three two and one.

134
00:07:22,040 --> 00:07:27,090
Okay so first of all what I will do I will print and okay.

135
00:07:27,120 --> 00:07:30,530
Because the value of this 5 5 is getting printed first.

136
00:07:30,530 --> 00:07:37,490
So first of all I will print that number and and then I will call the function and minus 1.

137
00:07:37,550 --> 00:07:38,200
So what.

138
00:07:38,240 --> 00:07:44,600
And minus 1 will do so and minus 1 will start bringing the numbers from and minus 1 then and minus 2

139
00:07:45,080 --> 00:07:46,050
L1.

140
00:07:46,350 --> 00:07:47,050
Okay.

141
00:07:47,060 --> 00:07:53,110
And first of all and we'll get printed and our book was also the same.

142
00:07:53,240 --> 00:07:55,790
We have to print the numbers in descending order.

143
00:07:55,790 --> 00:07:59,970
Okay so first I have to print n and then I will call.

144
00:07:59,990 --> 00:08:02,500
I will call the same function here.

145
00:08:02,630 --> 00:08:04,130
It will be the opposite of this.

146
00:08:04,130 --> 00:08:11,030
So first I was calling and minus 1 and then I was printing and but here first I will print n and then

147
00:08:11,120 --> 00:08:12,470
I will call and minus 1.

148
00:08:12,800 --> 00:08:16,310
Okay so basically defending or there will be the opposite of the ascending order.

149
00:08:16,950 --> 00:08:17,440
Okay.

150
00:08:17,600 --> 00:08:20,000
So what I will do.

151
00:08:20,000 --> 00:08:22,470
Let's write print to function.

152
00:08:22,460 --> 00:08:23,720
Let's copy discord

153
00:08:26,790 --> 00:08:29,490
so this is print to function.

154
00:08:29,490 --> 00:08:33,180
Now what I have to do I have to just change the order of these two lines.

155
00:08:33,240 --> 00:08:35,190
So first I will print n

156
00:09:01,270 --> 00:09:01,690
okay.

157
00:09:01,800 --> 00:09:05,450
So this will be our print to function so print to function what it does is.

158
00:09:05,530 --> 00:09:07,030
So this is our base case.

159
00:09:07,050 --> 00:09:11,770
Now first I will print n and then I will call and minus 1.

160
00:09:11,790 --> 00:09:14,090
So sorry this will be print too.

161
00:09:14,190 --> 00:09:15,930
Okay print to function.

162
00:09:15,930 --> 00:09:24,160
So what this function will do it will start printing the numbers from N minus 1 bill when.

163
00:09:24,230 --> 00:09:27,670
Okay so this will be the output of this line.

164
00:09:27,670 --> 00:09:34,480
But before the output of this line I am printing and OK now let's call print to function.

165
00:09:34,480 --> 00:09:39,850
So I am calling pen to function and I'm giving five his input so our output will be five four three

166
00:09:39,850 --> 00:09:40,630
two and one.

167
00:09:40,690 --> 00:09:43,660
OK so let's write a novel called

168
00:09:46,620 --> 00:09:49,090
so all our output is 5 4 2 2 and 1.

169
00:09:49,110 --> 00:09:53,580
Now after writing the code what we have to do we have to do that and have a code so that we can understand

170
00:09:53,580 --> 00:09:55,080
what is going on here.

171
00:09:55,110 --> 00:09:55,580
Okay.

172
00:09:55,710 --> 00:09:57,210
So the value of end is five.

173
00:09:57,580 --> 00:09:59,660
Okay so this is five.

174
00:09:59,730 --> 00:10:01,650
And I will write my output here.

175
00:10:01,800 --> 00:10:05,250
Okay so 5 is not close to zero C out.

176
00:10:05,250 --> 00:10:11,860
And so five will get printed and then I am calling print to function with the value in minus one.

177
00:10:11,880 --> 00:10:12,390
Okay.

178
00:10:12,570 --> 00:10:17,550
So the value of this food for is not too close to zero C out and so forth will get printed.

179
00:10:17,730 --> 00:10:20,650
Then we are calling with a smaller function.

180
00:10:20,670 --> 00:10:24,830
Okay I will call entre then t will get printed.

181
00:10:24,830 --> 00:10:31,660
I will call on when I will call in to do is not close to zero then I will print to then to really call

182
00:10:31,660 --> 00:10:32,940
on 1.

183
00:10:32,950 --> 00:10:35,290
So 1 is not close to zero.

184
00:10:35,290 --> 00:10:41,920
So I will print one then I will call on zero so zero equals zero then I have what I will do I will have

185
00:10:41,920 --> 00:10:46,840
done so I will have done so when I was waiting at line number 26.

186
00:10:46,840 --> 00:10:51,200
Okay this one was waiting at line number 26 then return.

187
00:10:51,390 --> 00:10:52,440
So it is done.

188
00:10:52,540 --> 00:10:55,000
Who was also waiting at line number 26.

189
00:10:55,150 --> 00:10:57,630
And then you're done so I will are done.

190
00:10:57,640 --> 00:10:59,960
He was waiting at Lam 9 number 26.

191
00:11:00,130 --> 00:11:01,470
Then it will get done.

192
00:11:01,560 --> 00:11:03,510
Ford was also waiting at number 26.

193
00:11:03,520 --> 00:11:05,050
Then you're done.

194
00:11:05,260 --> 00:11:08,140
And then five was also waiting at line number 26.

195
00:11:08,140 --> 00:11:13,620
And then you're done so get it done so and this is our output five four three two one.

196
00:11:13,690 --> 00:11:14,050
Okay.

197
00:11:14,920 --> 00:11:18,460
So I hope you understand the code how it is working.

198
00:11:18,490 --> 00:11:18,990
Okay.

199
00:11:19,060 --> 00:11:22,640
So writing this down part writing this written statement is optional here.

200
00:11:22,660 --> 00:11:24,370
If you want you can remove it also.

201
00:11:24,370 --> 00:11:25,690
Okay.

202
00:11:26,320 --> 00:11:33,310
For example let's remove this line and then also have a quota of accord will work because the function

203
00:11:33,340 --> 00:11:38,560
ends here and if the function ended it automatically means that are done okay with the void.

204
00:11:38,560 --> 00:11:40,340
You have option to return.

205
00:11:40,720 --> 00:11:44,160
This is optional here but writing return here is mandatory.

206
00:11:44,170 --> 00:11:44,830
Okay.

207
00:11:44,830 --> 00:11:48,630
Writing the written statement inside the f is mandatory.

208
00:11:48,640 --> 00:11:57,420
Okay so this done is compulsory otherwise what will happen if I will order write the return statement.

209
00:11:57,420 --> 00:11:58,010
What will happen.

210
00:11:58,020 --> 00:12:00,990
I will come at line number 22 which is wrong.

211
00:12:00,990 --> 00:12:01,610
Okay.

212
00:12:01,860 --> 00:12:04,250
So writing that are done is mandatory here.

213
00:12:06,930 --> 00:12:09,050
But this is done is optional.

214
00:12:09,120 --> 00:12:09,640
Okay.

215
00:12:11,930 --> 00:12:14,020
And also this are done is optional.

216
00:12:16,250 --> 00:12:18,490
Now I command out the certain part.

217
00:12:18,500 --> 00:12:21,670
Now if we will run our program our program will still work fine.

218
00:12:21,820 --> 00:12:23,630
Our output to live a full crew to anyone.

219
00:12:23,870 --> 00:12:31,700
Okay so I hope you understand why this redundant mandatory I am led straight to so it is a value of

220
00:12:31,760 --> 00:12:32,390
industry.

221
00:12:32,410 --> 00:12:35,420
Let's say I am calling in to function what the value of industry.

222
00:12:35,730 --> 00:12:39,530
So 3 what will happen 3 will call on 2 2 will call and 1.

223
00:12:39,620 --> 00:12:42,930
Now one will call and zero so zero equals zero.

224
00:12:42,950 --> 00:12:46,370
So if you will not write the return statement what will happen.

225
00:12:46,370 --> 00:12:50,040
So zero will come here see out zero so zero will get.

226
00:12:50,060 --> 00:12:51,290
This is our output.

227
00:12:51,380 --> 00:12:52,170
So what will happen.

228
00:12:52,160 --> 00:12:56,380
Zero will get painted Okay so this is brand to function.

229
00:12:56,390 --> 00:12:57,200
So what will happen.

230
00:12:57,200 --> 00:12:59,240
Our output is 3 to 1.

231
00:12:59,570 --> 00:13:01,740
Now what will happen the value of n is zero.

232
00:13:01,850 --> 00:13:02,900
So zero equals zero.

233
00:13:02,900 --> 00:13:05,630
But if the return statement is not here then what will happen.

234
00:13:05,630 --> 00:13:12,590
I will come at 9 number 23 so 0 1 get printed then I what I will do I will call on it to function and

235
00:13:12,590 --> 00:13:13,100
minus 1.

236
00:13:13,130 --> 00:13:19,460
So it will call on minus 1 then minus 1 will get printed it will equal and minus 2 it will equal and

237
00:13:19,460 --> 00:13:20,600
minus 3 and so on.

238
00:13:20,600 --> 00:13:23,750
Basically infinite loop problem will be there.

239
00:13:23,750 --> 00:13:25,700
Okay so infinite loop problem will be there.

240
00:13:25,700 --> 00:13:27,750
That's why this return is mandatory here.

241
00:13:27,770 --> 00:13:29,300
If this are done is there what will happen.

242
00:13:29,300 --> 00:13:30,470
I will return from zero.

243
00:13:31,000 --> 00:13:31,250
Okay.

244
00:13:31,260 --> 00:13:33,720
And this will not happen.

245
00:13:33,830 --> 00:13:38,470
Okay so this return is mandatory and it is this written is optional.

246
00:13:38,690 --> 00:13:38,990
Okay.

247
00:13:42,320 --> 00:13:45,440
And similarly for this one also Fort Bend function.

248
00:13:45,440 --> 00:13:47,020
Okay.

249
00:13:47,480 --> 00:13:48,500
What will happen.

250
00:13:48,500 --> 00:13:51,830
Suppose the value of and is 3.

251
00:13:52,040 --> 00:13:54,710
Now what will happen and is not close to zero.

252
00:13:54,710 --> 00:13:56,890
This this is our output.

253
00:13:56,890 --> 00:13:58,490
I am calling one smaller part.

254
00:13:58,490 --> 00:14:03,400
So 2 2 will call on 1 1 will call on 0.

255
00:14:03,470 --> 00:14:05,310
Okay so zero equals zero.

256
00:14:05,330 --> 00:14:07,640
So if the return statement is data what will happen.

257
00:14:07,640 --> 00:14:11,630
I will come at 1 and then one will get printed.

258
00:14:11,630 --> 00:14:16,750
But if this written statement is not there what will happen.

259
00:14:16,970 --> 00:14:18,510
What will happen when I call on.

260
00:14:18,520 --> 00:14:19,690
It also the requisite.

261
00:14:19,760 --> 00:14:21,080
The written statement is not there.

262
00:14:21,110 --> 00:14:23,200
Then I will come here at line number eleven.

263
00:14:23,210 --> 00:14:29,080
I will call minus 1 then minus and will call on minus 2 minus 2 will call on minus 3 and so on.

264
00:14:29,090 --> 00:14:31,720
Basically infinite loop problem will be there.

265
00:14:31,760 --> 00:14:33,670
That's why return is mandatory here.

266
00:14:33,680 --> 00:14:35,030
Okay.

267
00:14:35,060 --> 00:14:38,190
Inside the base case returns treatment is mandatory.

268
00:14:38,240 --> 00:14:38,450
Okay.

269
00:14:38,450 --> 00:14:40,520
Remember this thing.

270
00:14:40,520 --> 00:14:41,950
So I hope you understood the school.

271
00:14:42,300 --> 00:14:43,300
Okay thank you.
