1
00:00:01,440 --> 00:00:02,170
Hi, everyone.

2
00:00:02,190 --> 00:00:06,210
So in this video, we are going to solve this question, Jack Element, Besant Inari.

3
00:00:07,510 --> 00:00:09,670
So we need to solve this question using equation.

4
00:00:10,840 --> 00:00:15,730
We can easily solve this question with the help of our Lopevi look, but since we are learning it so

5
00:00:15,730 --> 00:00:19,190
we will use it to solve this question, the question is very simple.

6
00:00:19,480 --> 00:00:20,410
So given an every.

7
00:00:22,500 --> 00:00:24,450
So inside out, you will have many elements.

8
00:00:24,960 --> 00:00:27,180
So you want to search for a value, let's say.

9
00:00:27,780 --> 00:00:32,920
So if the value of X is five, so you have to tell whether five is present in the area or not.

10
00:00:33,090 --> 00:00:35,490
So if five is present, you need to return.

11
00:00:35,490 --> 00:00:39,300
True, if the value of X effects is not present in the area.

12
00:00:39,330 --> 00:00:40,300
I will return false.

13
00:00:40,740 --> 00:00:45,180
So you just have to check whether the element is present in the area or not.

14
00:00:45,600 --> 00:00:48,750
So our function function rebel.

15
00:00:49,850 --> 00:00:54,390
Function will take it as input and it will take size as input.

16
00:00:54,680 --> 00:00:59,400
So since we are going to use recursion, so I told you there are two ways of making already.

17
00:00:59,630 --> 00:01:03,320
So first of all, is like this will break the idea like this.

18
00:01:03,320 --> 00:01:07,550
And the second way of using recursion, and that is it will break our array like this.

19
00:01:08,660 --> 00:01:10,550
So let's discuss both the approaches.

20
00:01:10,580 --> 00:01:12,300
So first, let's discuss this approach.

21
00:01:12,590 --> 00:01:13,370
So what will do?

22
00:01:14,600 --> 00:01:15,470
This is already.

23
00:01:16,730 --> 00:01:19,450
So I will take a value X, which we need to find.

24
00:01:19,840 --> 00:01:23,210
So what if I am splitting my if I'm breaking my error like this?

25
00:01:23,540 --> 00:01:25,510
So I will work only on this part.

26
00:01:25,730 --> 00:01:26,900
So first of all, I will check.

27
00:01:27,110 --> 00:01:28,320
So if this value.

28
00:01:28,340 --> 00:01:36,860
So if they Nix's it also if you offer zero as it goes to the value of X, that means X is present here.

29
00:01:36,890 --> 00:01:41,840
So in that case, I will return to I have to return a boolean value so I will return true.

30
00:01:42,410 --> 00:01:43,730
Otherwise I will lose.

31
00:01:43,730 --> 00:01:45,860
So I will call the equation on the rest of the area.

32
00:01:46,400 --> 00:01:51,250
So this is a and this is a plus and a number of elements and minus one.

33
00:01:51,470 --> 00:01:55,170
So I will call the equation on the side and the question will return the answer.

34
00:01:55,580 --> 00:01:56,390
True or false.

35
00:01:56,720 --> 00:01:57,040
True.

36
00:01:57,170 --> 00:02:03,590
If the value X is present in this small area and the equation will return, false equation will return

37
00:02:03,590 --> 00:02:05,970
false if the value is not present in this small.

38
00:02:05,970 --> 00:02:07,110
Very simple.

39
00:02:07,640 --> 00:02:08,690
So let's write the code.

40
00:02:08,930 --> 00:02:09,970
So what do you want to do?

41
00:02:12,850 --> 00:02:15,290
Level and we just need to check.

42
00:02:16,170 --> 00:02:17,910
So is president.

43
00:02:20,050 --> 00:02:23,710
Of the function is as pleasant, it will take it as input.

44
00:02:24,770 --> 00:02:26,480
And we will take how many elements?

45
00:02:28,710 --> 00:02:32,570
And will take a value X, which we need to find out.

46
00:02:33,530 --> 00:02:34,850
So basically, it's a very simple.

47
00:02:36,170 --> 00:02:42,210
If size is zero, if my head is empty, so if it is empty, it will likely return false.

48
00:02:42,920 --> 00:02:46,210
If that is empty value X cannot be present inside already.

49
00:02:46,550 --> 00:02:47,720
So I will return false.

50
00:02:50,340 --> 00:02:51,180
So first of all.

51
00:02:52,230 --> 00:02:54,490
This is the area I'm standing here.

52
00:02:55,080 --> 00:02:58,680
So this is the next first I will check whether here or not.

53
00:02:59,100 --> 00:03:02,130
So let's check where the next president or not.

54
00:03:02,400 --> 00:03:03,090
So if.

55
00:03:04,530 --> 00:03:05,400
AOF zero.

56
00:03:06,550 --> 00:03:10,600
Is equals two X. So in this case, I will return to.

57
00:03:11,870 --> 00:03:15,710
I find out x axis in that desert, and so I will return to.

58
00:03:16,700 --> 00:03:22,880
So if this is not the case, so what I will do, I will call the Guardian on this small lady, so this

59
00:03:22,880 --> 00:03:26,420
is a plus one and number of celebrities and minus one.

60
00:03:26,690 --> 00:03:29,710
So if it turns true, that means X is present.

61
00:03:29,750 --> 00:03:30,500
So I will return.

62
00:03:30,500 --> 00:03:30,770
True.

63
00:03:31,310 --> 00:03:39,380
If it is false, that means X is not present here and zero zero is also not equal to X, so I will return

64
00:03:39,380 --> 00:03:39,740
false.

65
00:03:40,160 --> 00:03:41,830
So basically I just need to return.

66
00:03:41,840 --> 00:03:46,670
Basically I just need to return the answer of this Mollari and that will be my final answer.

67
00:03:47,750 --> 00:03:50,070
So the answer to this Mollari will be my final answer.

68
00:03:50,360 --> 00:03:54,500
So like Lyttleton, let's copy the name of the function is present.

69
00:03:56,950 --> 00:03:59,230
As president, we will give every.

70
00:04:00,310 --> 00:04:03,550
That is a plus one number of elements and minus one.

71
00:04:04,980 --> 00:04:09,080
And minus one, and the value which you want to search for is X.

72
00:04:10,950 --> 00:04:12,300
So let's call this function.

73
00:04:14,950 --> 00:04:22,330
So the function is present if it's present at a number of elements, five, and I want to search for

74
00:04:22,330 --> 00:04:22,630
three.

75
00:04:24,070 --> 00:04:26,260
So let's bring the message here.

76
00:04:27,600 --> 00:04:28,110
Found.

77
00:04:33,920 --> 00:04:36,350
In the last part, we're going to bring in our town.

78
00:04:43,310 --> 00:04:44,660
So let's test.

79
00:04:46,180 --> 00:04:48,860
So please present to you present in the area.

80
00:04:48,900 --> 00:04:50,290
That's why the output is found.

81
00:04:51,100 --> 00:04:52,450
So let's write a novel called.

82
00:04:56,060 --> 00:04:58,370
So basically, this is our area, one, two, three, four, five.

83
00:05:00,490 --> 00:05:09,310
And number five, so size is not zero and the zero element, so one is not equal to X is basically five,

84
00:05:09,310 --> 00:05:10,340
X is basically three.

85
00:05:10,390 --> 00:05:13,090
This is the value of X, so one is not the to three.

86
00:05:13,390 --> 00:05:16,600
So I will call on this one, three, four, two, three, four and five.

87
00:05:18,140 --> 00:05:23,000
Two, three, four and five, a number of elements for and the value of X is remaining same, so the

88
00:05:23,000 --> 00:05:23,870
value of X is three.

89
00:05:24,880 --> 00:05:29,460
Size is not zero and two is not equal to three, so I will call on this Mollari.

90
00:05:31,200 --> 00:05:32,190
Three, four and five.

91
00:05:32,490 --> 00:05:34,540
Number three, the value of X history.

92
00:05:34,980 --> 00:05:40,780
So now size is not zero, but X is equal to the first element.

93
00:05:40,800 --> 00:05:42,410
So excessive collateral of zero.

94
00:05:42,420 --> 00:05:43,190
So I will return.

95
00:05:43,220 --> 00:05:43,460
True.

96
00:05:43,860 --> 00:05:45,510
So I will return to.

97
00:05:47,070 --> 00:05:52,180
So basically is present in this very experiment in decided, that's why I'm getting through.

98
00:05:52,650 --> 00:05:55,730
So whatever value you are getting, just done that.

99
00:05:56,040 --> 00:05:56,900
So I'm getting through.

100
00:05:56,910 --> 00:05:59,270
So just don't do so.

101
00:05:59,580 --> 00:06:01,200
So three percent in this area.

102
00:06:01,260 --> 00:06:05,490
Whatever value you are getting from the equation, just like that value.

103
00:06:05,500 --> 00:06:06,420
So I will return to.

104
00:06:07,570 --> 00:06:10,660
So if I'm returning to this condition is true, I will be found.

105
00:06:11,020 --> 00:06:14,370
So let's take one more example in which the element is not present.

106
00:06:14,380 --> 00:06:16,970
So I want to search for sex and sex is not present.

107
00:06:16,970 --> 00:06:18,340
So the output should be not found.

108
00:06:20,230 --> 00:06:22,480
So the output is coming out to be not found.

109
00:06:24,800 --> 00:06:26,480
So now let's see how it will work.

110
00:06:26,870 --> 00:06:28,370
So if this is already.

111
00:06:31,650 --> 00:06:33,600
Elements are one, two, three, four and five.

112
00:06:34,990 --> 00:06:42,220
Number five, the value of X history, and this is the value of any size is not zero and one is not

113
00:06:42,220 --> 00:06:42,870
equal to three.

114
00:06:43,210 --> 00:06:44,800
So we will call on this, Mollari.

115
00:06:46,360 --> 00:06:52,570
This is two, three, four and five number of elements for value of accessory sizes, not zero.

116
00:06:52,720 --> 00:06:55,390
And the first element, two is not close to three.

117
00:06:55,390 --> 00:07:00,310
So I will call on this, Mollari, so I will call on three, four and five number of elements, three

118
00:07:01,150 --> 00:07:02,440
and the value of X history.

119
00:07:04,210 --> 00:07:10,780
OK, so the value of X versus the value of X is six, the value of X is six, sorry.

120
00:07:11,860 --> 00:07:15,820
So size is not zero and six is not equal to three.

121
00:07:15,820 --> 00:07:17,190
So I will call on this Mollari.

122
00:07:17,200 --> 00:07:18,550
So I will call on four and five.

123
00:07:19,590 --> 00:07:21,290
Number of elements is to.

124
00:07:22,350 --> 00:07:29,280
The value of ethics, so size is not zero and four is not close to six, so I will call on the smaller

125
00:07:30,180 --> 00:07:30,690
sizes.

126
00:07:30,690 --> 00:07:37,670
One say it is not zero and the first element, the first element, five is not equal to six.

127
00:07:38,010 --> 00:07:39,260
So I will call on the empty.

128
00:07:40,050 --> 00:07:45,000
So I'm calling on the empty added number of elements is zero and the value which you are searching for

129
00:07:45,000 --> 00:07:45,420
is six.

130
00:07:45,630 --> 00:07:48,950
So I have decided zero have decided zero return false.

131
00:07:49,080 --> 00:07:50,140
So I will return false.

132
00:07:50,580 --> 00:07:55,380
So whatever value you are getting from the equation, you are just likely returning that value.

133
00:07:55,390 --> 00:07:56,390
So I will unfold.

134
00:07:56,940 --> 00:07:58,010
I will return false.

135
00:07:58,500 --> 00:07:59,580
I will return false.

136
00:08:00,060 --> 00:08:01,130
I will return false.

137
00:08:01,140 --> 00:08:02,750
And finally I will return false.

138
00:08:03,060 --> 00:08:05,420
So that's why the output is coming out to be not found.

139
00:08:06,180 --> 00:08:07,440
So currently what we are doing.

140
00:08:07,980 --> 00:08:09,720
So if this is Mary.

141
00:08:11,710 --> 00:08:19,790
So first, I am checking whether this value is equal to X or not, and then I am calling on that equation

142
00:08:19,810 --> 00:08:21,750
and then I'm calling it a collision on this Mollari.

143
00:08:22,110 --> 00:08:26,710
OK, you can see first I am checking and then I am calling so we can do the opposite.

144
00:08:26,710 --> 00:08:27,590
Also what they can do.

145
00:08:27,610 --> 00:08:28,300
So first.

146
00:08:29,400 --> 00:08:34,659
Let's first check whether expert in this area or not, so let's call that equation for this.

147
00:08:35,700 --> 00:08:37,020
Well, first check this.

148
00:08:37,409 --> 00:08:38,309
I will parsecs.

149
00:08:38,520 --> 00:08:39,770
So it will return to things.

150
00:08:39,780 --> 00:08:41,890
It will return to or it will return false.

151
00:08:42,360 --> 00:08:45,910
So if it returns through, that means the value that is present here.

152
00:08:46,080 --> 00:08:47,580
So my answer will be to.

153
00:08:49,220 --> 00:08:56,090
But if a return false, that means X is not present in this area, then we will check whether X is present

154
00:08:56,090 --> 00:08:57,140
at this next or not.

155
00:08:57,470 --> 00:09:02,670
So if it is false, then I will check if of zero equals equals X or not.

156
00:09:02,930 --> 00:09:05,810
So if X is present here, I will return.

157
00:09:05,810 --> 00:09:11,750
True, if X is not present here, I will return false so we can start a discussion like this one like

158
00:09:11,750 --> 00:09:12,300
this also.

159
00:09:12,530 --> 00:09:13,650
So let us write the code.

160
00:09:14,600 --> 00:09:15,650
Let's copy the function.

161
00:09:20,660 --> 00:09:21,980
So Bulle is presenta.

162
00:09:24,560 --> 00:09:26,980
This case will remain same now.

163
00:09:27,050 --> 00:09:28,190
We will remove it from here.

164
00:09:30,460 --> 00:09:33,370
So first, I need to check so bull.

165
00:09:35,420 --> 00:09:36,950
Let's say left president.

166
00:09:39,970 --> 00:09:42,440
Or let's call it smaller and smaller.

167
00:09:43,150 --> 00:09:47,280
Or let's call it lefty, so I'm calling this area as right, Teddy.

168
00:09:47,290 --> 00:09:48,370
So this is right, Teddy.

169
00:09:49,680 --> 00:09:52,470
So is the ex-president in the right area?

170
00:09:52,950 --> 00:09:59,390
This is right, Terry, so let's rename it or what else can we named a better name?

171
00:09:59,760 --> 00:10:01,890
So remaining at it, let's call it remaining at.

172
00:10:03,960 --> 00:10:07,980
So instead of Friday, let's call it remaining at a.

173
00:10:09,890 --> 00:10:10,610
So if.

174
00:10:11,740 --> 00:10:13,450
The value is found in the remaining.

175
00:10:14,500 --> 00:10:16,900
So if remaining, that is true.

176
00:10:17,260 --> 00:10:18,940
So in that case, I will return to.

177
00:10:21,570 --> 00:10:22,060
Simple.

178
00:10:22,740 --> 00:10:30,360
So what I'm doing, I'm calling the location, I'm calling the location and the output of this is basically

179
00:10:30,360 --> 00:10:31,230
the remaining area.

180
00:10:31,260 --> 00:10:32,930
I'm calling it location on the remaining area.

181
00:10:33,090 --> 00:10:33,960
So it will return.

182
00:10:33,960 --> 00:10:34,220
True.

183
00:10:34,440 --> 00:10:37,140
So if it is returning true, if it is true, then I am returning.

184
00:10:37,140 --> 00:10:37,390
True.

185
00:10:37,530 --> 00:10:37,920
Yes.

186
00:10:37,930 --> 00:10:39,370
The value is present here.

187
00:10:40,000 --> 00:10:41,280
Now at this line.

188
00:10:42,500 --> 00:10:43,500
The output is false.

189
00:10:43,520 --> 00:10:45,620
So now I will check for disvalue.

190
00:10:47,700 --> 00:10:48,790
So now let's check.

191
00:10:48,840 --> 00:10:56,460
So if aof zero equals equals X, then in that case you will return to.

192
00:10:57,970 --> 00:11:01,150
And the ultimate, you will return false.

193
00:11:03,150 --> 00:11:03,630
Simple.

194
00:11:05,160 --> 00:11:08,670
So now let us test this experimental.

195
00:11:10,100 --> 00:11:12,830
So six is not present, so the output should be not found.

196
00:11:15,540 --> 00:11:16,850
So the output is not found.

197
00:11:18,810 --> 00:11:24,360
So I did one mistake here, I am calling this president also I should write is president to hear.

198
00:11:25,600 --> 00:11:26,910
Let's test it one more time.

199
00:11:28,900 --> 00:11:35,590
So the output is not found and let's take a value, which is Besant, so I want to search for five,

200
00:11:35,770 --> 00:11:37,840
five is present, so output should be found.

201
00:11:38,810 --> 00:11:40,100
So the output is coming out.

202
00:11:40,130 --> 00:11:40,610
We found.

203
00:11:42,740 --> 00:11:44,870
Simple, so let's see how it is working.

204
00:11:44,900 --> 00:11:47,480
Let's take one example, let's take this example.

205
00:11:47,480 --> 00:11:48,830
Only one, two, three, four and five.

206
00:11:50,610 --> 00:11:56,280
So one, two, three, four and five number of elements is five, and the value of X is also five.

207
00:11:56,730 --> 00:12:01,320
So first of all, what you will do, you are calling you are just actually calling the recursion.

208
00:12:01,320 --> 00:12:03,370
You are passing the smaller number of elements.

209
00:12:03,390 --> 00:12:07,950
So I'm likely calling the recursion two, three, four and five.

210
00:12:08,790 --> 00:12:11,150
Now, a number of elements for the value of access.

211
00:12:11,160 --> 00:12:14,070
Five, again, size is not zero.

212
00:12:15,070 --> 00:12:21,610
So called recursion, three, four, five, three exits, five sizes, not zero, so called precaution

213
00:12:22,060 --> 00:12:26,290
four and five number of elements is to and I want to search for five.

214
00:12:26,500 --> 00:12:28,210
So again, the size is not zero.

215
00:12:28,210 --> 00:12:29,140
Size is not zero.

216
00:12:29,170 --> 00:12:32,860
So again, collocation on the small number of elements.

217
00:12:32,870 --> 00:12:34,900
One, the value of excess five.

218
00:12:34,930 --> 00:12:36,540
So again, the size is not zero.

219
00:12:36,880 --> 00:12:40,050
So you will call the equation and size becomes zero.

220
00:12:40,090 --> 00:12:41,310
You want to search for five.

221
00:12:41,650 --> 00:12:43,360
So it is a zero.

222
00:12:43,390 --> 00:12:46,390
If the size is really well done, false, you will return false.

223
00:12:48,190 --> 00:12:54,100
So this really is basically fault, so I will not go into effect, so I will reach here, I will check

224
00:12:54,100 --> 00:12:54,910
the first element.

225
00:12:55,030 --> 00:12:56,380
So first element is five.

226
00:12:56,830 --> 00:12:59,860
Now five is equal to the X, so you will return.

227
00:12:59,860 --> 00:13:00,120
True.

228
00:13:00,430 --> 00:13:01,840
So this thing will return to.

229
00:13:03,880 --> 00:13:08,740
So ForFour, you are getting through, you are getting through from the air.

230
00:13:09,190 --> 00:13:12,430
So that means the value of the remaining air is basically to.

231
00:13:13,810 --> 00:13:19,500
Because you are able to find the value of if you are able to find the value of life in the small area.

232
00:13:19,900 --> 00:13:22,620
So you are getting to see the value of remaining crystal.

233
00:13:22,660 --> 00:13:24,060
If it is true, you will return to.

234
00:13:24,520 --> 00:13:25,450
So you will return.

235
00:13:25,450 --> 00:13:25,690
True.

236
00:13:27,550 --> 00:13:30,980
So, again, you are able to find X in this area.

237
00:13:31,130 --> 00:13:32,350
That's why you are getting through.

238
00:13:32,620 --> 00:13:33,910
So the value is through.

239
00:13:33,910 --> 00:13:34,930
So you will return to.

240
00:13:38,010 --> 00:13:40,080
Now you are able to find.

241
00:13:41,230 --> 00:13:45,050
This X and this that's why you are getting through if you are getting through.

242
00:13:45,070 --> 00:13:46,240
If this is true, you will return.

243
00:13:46,240 --> 00:13:46,430
True.

244
00:13:47,350 --> 00:13:48,910
So now you are able to find.

245
00:13:49,960 --> 00:13:51,860
The value of X in this area.

246
00:13:52,030 --> 00:13:55,390
That's why you are getting through, so if the value is true, you will return.

247
00:13:55,390 --> 00:13:55,640
True.

248
00:13:55,870 --> 00:13:56,910
So I will return true.

249
00:13:57,430 --> 00:14:00,410
Since I'm getting through, I am printing this message found.

250
00:14:00,970 --> 00:14:02,340
So that's how it is working.

251
00:14:03,270 --> 00:14:04,290
So now I told you.

252
00:14:05,330 --> 00:14:08,600
There are two ways, so we write the code for this approach.

253
00:14:08,630 --> 00:14:10,770
Now let us also discuss this approach.

254
00:14:11,120 --> 00:14:16,550
So what will do if I will make my error like this, if my if I break my error like this?

255
00:14:16,590 --> 00:14:17,660
So first of all, this is.

256
00:14:17,660 --> 00:14:18,370
And my one.

257
00:14:18,680 --> 00:14:20,300
So first of all, I can check.

258
00:14:21,960 --> 00:14:24,090
Is the value X present here?

259
00:14:24,240 --> 00:14:29,190
So first of all, I can write a very simple check if the last element is, of course, two X, in that

260
00:14:29,190 --> 00:14:30,930
case, you found the element, so you will return.

261
00:14:30,960 --> 00:14:31,230
True.

262
00:14:31,740 --> 00:14:34,620
Otherwise, what you will do, you will call the recursion on this area.

263
00:14:36,320 --> 00:14:40,710
So this area will either return true or this area will either return false.

264
00:14:41,000 --> 00:14:46,160
So if the value is present, if the X is present in this area, then in that case my output will be

265
00:14:46,160 --> 00:14:46,420
true.

266
00:14:46,700 --> 00:14:50,480
If X is not present in this area, then in that case, my output will be false.

267
00:14:50,690 --> 00:14:53,590
So basically, if I'm getting through, I'm running through.

268
00:14:53,600 --> 00:14:55,400
If I'm getting false, I'm returning false.

269
00:14:55,640 --> 00:15:03,200
So basically we can just directly return the value of the onset of the smaller dancer for the smaller.

270
00:15:03,200 --> 00:15:05,060
It will be the answer for the big area also.

271
00:15:05,360 --> 00:15:05,810
OK.

272
00:15:06,080 --> 00:15:09,440
So now let's write the code and what is the idea.

273
00:15:09,470 --> 00:15:14,260
So it is the same, but the number of elements is less number of elements and minus one.

274
00:15:14,390 --> 00:15:17,540
But we are passing the completely so bulle.

275
00:15:19,000 --> 00:15:23,890
Is three, I will take it as input.

276
00:15:25,430 --> 00:15:27,450
Number of elements and ex.

277
00:15:29,050 --> 00:15:30,460
So this case will remain, Tim.

278
00:15:31,640 --> 00:15:33,680
If that isn't pretty, you will false.

279
00:15:36,240 --> 00:15:37,560
Either way, what you need to do.

280
00:15:37,800 --> 00:15:40,070
So, first of all, I will check the last element.

281
00:15:40,080 --> 00:15:41,370
So you have the last element.

282
00:15:42,980 --> 00:15:44,180
Is it close to X?

283
00:15:45,150 --> 00:15:47,160
Then in that case, I will return to.

284
00:15:49,740 --> 00:15:53,850
Otherwise, what they need to do, so I will call an equation on this Mollari.

285
00:15:55,160 --> 00:16:01,820
So let's copy this history, I am putting the complete number of elements and minus one.

286
00:16:02,870 --> 00:16:04,680
And the value is X.

287
00:16:06,140 --> 00:16:08,060
So let's call the function is presently.

288
00:16:11,990 --> 00:16:12,560
Let's see.

289
00:16:13,520 --> 00:16:14,670
So it should be found.

290
00:16:14,810 --> 00:16:15,960
So our report is coming out.

291
00:16:15,980 --> 00:16:16,430
We found.

292
00:16:18,220 --> 00:16:20,470
So let's underscore how it will work.

293
00:16:23,130 --> 00:16:24,600
One, two, three, four and five.

294
00:16:26,310 --> 00:16:29,550
I want to search a number of elements for if I want to search for five.

295
00:16:30,730 --> 00:16:36,100
Size is not zero, and the last element is equal to five, the last element is equal to five.

296
00:16:36,100 --> 00:16:37,440
Written to say Willerton to.

297
00:16:38,990 --> 00:16:45,230
Simple, so if the value which you want to so justly so, Teresa, also present over what will happen,

298
00:16:45,500 --> 00:16:48,500
size is not zero and five is not close to three.

299
00:16:48,500 --> 00:16:51,890
So you will call on this Mollari, you will call on one, two, three, four.

300
00:16:53,220 --> 00:16:56,270
Number of elements is for anyone to search for three.

301
00:16:57,350 --> 00:17:02,900
So size is not zero and four is not equal to three, so I will call on this Mollari one, two, three.

302
00:17:05,030 --> 00:17:11,990
Size number three, and you want to search for three sizes, not zero, but the last elementary is equal

303
00:17:11,990 --> 00:17:12,349
to three.

304
00:17:12,349 --> 00:17:13,400
So you will return to.

305
00:17:15,839 --> 00:17:17,310
If found, return to.

306
00:17:18,450 --> 00:17:24,170
So for this area I am getting through from the left side, I'm getting through from the left side,

307
00:17:24,180 --> 00:17:28,319
whatever value you are getting, just like Lyttleton, you are getting to return to.

308
00:17:30,160 --> 00:17:38,200
So for this area I am getting through from the left side, so that means to use the left side, so whatever

309
00:17:38,200 --> 00:17:41,030
value you are getting, just like any return that value.

310
00:17:41,060 --> 00:17:41,890
So I will return.

311
00:17:41,890 --> 00:17:42,100
True.

312
00:17:42,580 --> 00:17:43,840
So that's how it will work.

313
00:17:44,140 --> 00:17:47,390
So one thing, what is the difference between this approach and this approach?

314
00:17:47,410 --> 00:17:50,020
So what is the difference between this approach?

315
00:17:51,060 --> 00:17:56,430
And this approach, so the only defense is basically we are planning to close in on this, Eddie.

316
00:17:57,520 --> 00:17:59,800
Here we are playing accordion on this area.

317
00:18:00,820 --> 00:18:06,100
So basically, if you can see there are two ways of traversing the very first raised, I think the area

318
00:18:06,100 --> 00:18:10,600
like this, which is exactly like this approach, secondly of traversing the area.

319
00:18:10,630 --> 00:18:15,110
Basically, we can traverse from and to start, which is exactly like this.

320
00:18:15,370 --> 00:18:20,380
So basically, since there are two ways for traversing the area from start to end and we can also traverse

321
00:18:20,380 --> 00:18:21,780
the area from and to start.

322
00:18:22,780 --> 00:18:27,000
So that's where there are two ways of using the equation on Eddy.

323
00:18:27,160 --> 00:18:29,800
You can apply recursion from start to end like this.

324
00:18:29,800 --> 00:18:32,730
You can make the array like this and you can also make the array like this.

325
00:18:33,040 --> 00:18:34,570
So this is very similar to.

326
00:18:34,600 --> 00:18:35,730
So these are very similar.

327
00:18:35,740 --> 00:18:36,520
Exactly same.

328
00:18:36,880 --> 00:18:43,580
And similarly here we are moving from end to start and to like this, moving from and to start.

329
00:18:43,900 --> 00:18:48,610
So I told you that there is one more approach in next I approach.

330
00:18:48,910 --> 00:18:51,070
So let's use your next high approach.

331
00:18:51,070 --> 00:18:52,450
Let's write the call for index.

332
00:18:52,460 --> 00:18:53,050
I also.

333
00:18:54,950 --> 00:18:57,950
So we will take a variable in next, how do I treat ordinary?

334
00:19:01,090 --> 00:19:02,530
So Bulle is presently.

335
00:19:03,600 --> 00:19:09,000
It's president for I am taking it and put into an.

336
00:19:09,970 --> 00:19:16,190
And X and I, so I'm using I will use variable to write over the area.

337
00:19:16,990 --> 00:19:18,760
So what I want to say here is.

338
00:19:20,040 --> 00:19:20,780
This is your area.

339
00:19:21,820 --> 00:19:25,930
This is index and minus one, and this is the last index and which does not exist.

340
00:19:26,400 --> 00:19:27,380
This is a net zero.

341
00:19:27,810 --> 00:19:29,420
So in error.

342
00:19:30,000 --> 00:19:35,550
So if this is already we can use a for a loop to iterate over the area to this recursive approach is

343
00:19:35,550 --> 00:19:36,140
very similar.

344
00:19:36,150 --> 00:19:41,070
You are taking a variable index, you're taking an index, i.e. the value of I will be zero, I will

345
00:19:41,070 --> 00:19:43,670
pass Valerii zero from mean.

346
00:19:43,950 --> 00:19:48,310
So what I will do, I will traverse over this area and then I will reach here.

347
00:19:48,810 --> 00:19:55,040
So when the value of it becomes and so I will start Diversey when I, when I becomes.

348
00:19:55,050 --> 00:19:57,480
And so that means value not found.

349
00:19:58,650 --> 00:19:59,700
Well, not found.

350
00:20:01,080 --> 00:20:06,660
You want to search for X, so if you reach and so, for example, when you're traversing here, if you

351
00:20:06,660 --> 00:20:09,060
reach the lasting X, that means the value is not present.

352
00:20:09,270 --> 00:20:12,230
Similarly, if I become, then that means the value not found.

353
00:20:12,450 --> 00:20:14,000
If you found the value in between.

354
00:20:14,040 --> 00:20:15,150
Then you will return to.

355
00:20:16,560 --> 00:20:21,890
Simple, so here what he used to write like this, if you are using AI Group, reverse psychology.

356
00:20:22,170 --> 00:20:23,550
Lieutenant Shapelessness.

357
00:20:23,940 --> 00:20:28,830
So if Yoffie is equal to X, you will return.

358
00:20:28,830 --> 00:20:29,070
True.

359
00:20:29,220 --> 00:20:30,240
So this is for loop.

360
00:20:31,240 --> 00:20:36,490
This is what you will write using for loop, so we will we are just trying to simulate that approach

361
00:20:36,490 --> 00:20:36,700
here.

362
00:20:37,090 --> 00:20:38,130
We are passing a variable.

363
00:20:38,800 --> 00:20:45,400
If I listen after everything, the whole area, if I am not able to find the value inside the array,

364
00:20:45,400 --> 00:20:49,670
I will return false value not found if the value is present in between the array.

365
00:20:49,760 --> 00:20:51,110
If the values present in the area.

366
00:20:51,940 --> 00:20:57,370
So in that case, what will happen if I will become equals to X and in that case I will return.

367
00:20:57,370 --> 00:20:57,620
True.

368
00:20:57,880 --> 00:20:58,720
So you can see.

369
00:21:00,000 --> 00:21:05,070
We are just trying to simulate the follow up approach, using the recursion by just taking a variable

370
00:21:05,070 --> 00:21:05,340
eye.

371
00:21:06,210 --> 00:21:07,260
So let's write the code.

372
00:21:08,400 --> 00:21:09,510
So what is the best case?

373
00:21:09,540 --> 00:21:16,480
So if I become sequel's to end after I think the whole area, if I reaches and or the other way to say

374
00:21:16,480 --> 00:21:18,930
is basically if that is empty.

375
00:21:19,290 --> 00:21:28,380
So you can see this line in this if it is the last or next or if that is empty, then the value is not

376
00:21:28,380 --> 00:21:28,770
present.

377
00:21:28,780 --> 00:21:30,660
So in that case, you will return false.

378
00:21:32,320 --> 00:21:34,220
Otherwise, you can check.

379
00:21:34,360 --> 00:21:38,490
So if if I is it close to X?

380
00:21:38,530 --> 00:21:40,810
So in that case, you will return to.

381
00:21:42,580 --> 00:21:47,290
Otherwise, what you will do, you will call this function is pleasant for.

382
00:21:52,130 --> 00:21:52,980
You will get better.

383
00:21:53,060 --> 00:21:55,920
You will give any number of elements will not decrease.

384
00:21:56,090 --> 00:21:59,090
You will give X and you will give a plus one.

385
00:22:00,370 --> 00:22:02,500
See, what I'm doing here is.

386
00:22:03,940 --> 00:22:11,050
So here I used to write a placeless so check check out the current position, if not present Movahed,

387
00:22:11,350 --> 00:22:13,760
check out this position, if not present, move ahead.

388
00:22:13,990 --> 00:22:15,400
So basically, I am checking.

389
00:22:15,640 --> 00:22:17,740
I am checking and I am moving ahead.

390
00:22:18,160 --> 00:22:22,780
What I'm doing here, I am checking if found return true otherwise for moving ahead.

391
00:22:22,930 --> 00:22:24,140
I am doing a plus one.

392
00:22:24,850 --> 00:22:30,460
See, we are just trying to simulate the for loop approach using the recursion I am explaining one more

393
00:22:30,460 --> 00:22:30,760
time.

394
00:22:32,240 --> 00:22:37,940
Check at the current position, check out the current position, if found, return to check out the

395
00:22:37,940 --> 00:22:38,660
current position.

396
00:22:38,660 --> 00:22:40,040
If found, return to.

397
00:22:41,310 --> 00:22:43,740
If not found, move to the next position.

398
00:22:44,850 --> 00:22:48,910
Basically a plus plus, similarly, if not found, move to the next position.

399
00:22:49,110 --> 00:22:51,030
So this is for moving to next position.

400
00:22:51,690 --> 00:22:55,440
And finally, if the loop gets over, if you reach at this line.

401
00:22:55,450 --> 00:22:57,390
So what is the meaning at this line?

402
00:22:57,780 --> 00:23:02,800
If I become second to and then in that case, you will return false value not found.

403
00:23:03,570 --> 00:23:10,200
So similarly, we are trading we are just ideating over the and if I reach the last index, the value

404
00:23:10,200 --> 00:23:12,840
is not present, so I will return false.

405
00:23:14,170 --> 00:23:19,090
So let's test let's call this function is present for and then we will Dhiren also.

406
00:23:21,600 --> 00:23:22,650
Is President Ford.

407
00:23:24,180 --> 00:23:29,610
Let's say I want to search for food and we need to pass the value of I so I is zero.

408
00:23:30,740 --> 00:23:34,180
I will start from I will start searching the area from index zero.

409
00:23:34,260 --> 00:23:36,890
OK, I will start searching the area from Exito.

410
00:23:39,790 --> 00:23:41,080
So it will be found.

411
00:23:42,590 --> 00:23:47,010
So I would put this phone and similarly, if you will give another element, which is not pleasant,

412
00:23:47,030 --> 00:23:47,510
let's say.

413
00:23:48,550 --> 00:23:48,980
Zero.

414
00:23:49,520 --> 00:23:54,090
Let's say sorry, let's say you want to search for zero zero zero is not present inside this area,

415
00:23:54,430 --> 00:23:56,350
so it will be false, not found.

416
00:23:57,600 --> 00:23:58,930
So zero is not pleasant.

417
00:23:59,430 --> 00:24:05,700
So now let's batten, although I think there's no need to underscore, it's very simple, but let's

418
00:24:05,700 --> 00:24:09,040
write in so that you can so you guys can have a better understanding.

419
00:24:09,450 --> 00:24:10,410
So this is the Eddie.

420
00:24:11,760 --> 00:24:17,600
The value of any number of elements, five, let's say I want to search for four and the value of a

421
00:24:17,620 --> 00:24:18,860
zero, I am passing zero.

422
00:24:19,110 --> 00:24:20,160
So this is a.

423
00:24:21,330 --> 00:24:28,850
So sources, first of all, I'm checking I is not equal to zero, is not close to five and one is not

424
00:24:28,850 --> 00:24:29,520
equal to four.

425
00:24:30,260 --> 00:24:32,390
So in that case, I will call on this Mollari.

426
00:24:34,220 --> 00:24:41,780
Two, three, four, five and one, so a number of elements will remain the same remains same size and

427
00:24:41,810 --> 00:24:47,070
same sex remains same, so the same X will remain same and the value of five will become one.

428
00:24:48,020 --> 00:24:54,490
So one is not close to five and this is a two is not close to four.

429
00:24:54,740 --> 00:24:55,820
So we will move ahead.

430
00:24:57,610 --> 00:25:01,540
So this is one, then two, then three, then four and then five.

431
00:25:02,610 --> 00:25:10,010
Number of elements to maintain X and the value of, I don't know, so two is not close to five and this

432
00:25:10,010 --> 00:25:10,420
is a.

433
00:25:10,640 --> 00:25:12,940
So three is not equal to four.

434
00:25:13,700 --> 00:25:14,510
So what will happen?

435
00:25:14,510 --> 00:25:15,380
You will move ahead.

436
00:25:17,130 --> 00:25:27,120
So one, two, three, four and five and five X is four, and the value of eye is three, so three is

437
00:25:27,120 --> 00:25:28,180
not equal to five.

438
00:25:28,230 --> 00:25:29,100
This is a.

439
00:25:31,260 --> 00:25:34,980
Four, is it close to four, so Alphie, is it close to you, Will?

440
00:25:35,550 --> 00:25:36,540
So I will return to.

441
00:25:37,870 --> 00:25:42,700
Whatever value you are getting from the record, just like Lyttleton, so I will return to I will return

442
00:25:42,700 --> 00:25:42,980
true.

443
00:25:43,180 --> 00:25:44,760
And finally I will return true.

444
00:25:45,100 --> 00:25:49,420
So basically for this present, I decided that I am getting return.

445
00:25:49,720 --> 00:25:50,770
That's why I am getting through.

446
00:25:51,200 --> 00:25:56,920
Now, can you observe first the value of five zero, now the value of Aizman.

447
00:25:56,950 --> 00:25:59,460
Now the value of I used to and now the value of Estie.

448
00:25:59,650 --> 00:26:04,070
So we are just linearly trading over the area exactly like the for loop.

449
00:26:04,390 --> 00:26:06,520
So this is very similar to for loop.

450
00:26:06,940 --> 00:26:08,800
We are just iterating over the.

451
00:26:09,220 --> 00:26:13,990
You can see the value of 5.0, then it becomes one, then it becomes two, then it becomes three.

452
00:26:14,200 --> 00:26:16,310
And similarly it will keep increasing.

453
00:26:16,330 --> 00:26:20,890
And finally, if I will reach the index and then I will return false.

454
00:26:20,900 --> 00:26:22,780
That means the value is not present.

455
00:26:22,780 --> 00:26:25,020
And whatever value you are getting, you are just dagbladet.

456
00:26:25,930 --> 00:26:31,150
So, for example, if you want to search for, let's say, six, so six is not present, so you will

457
00:26:31,150 --> 00:26:31,990
call ahead.

458
00:26:32,930 --> 00:26:39,310
You will call one, two, three, four and five, five, six, and the of I will become four.

459
00:26:39,590 --> 00:26:40,590
So now you will check.

460
00:26:40,820 --> 00:26:42,160
So I is present here.

461
00:26:42,380 --> 00:26:46,490
So you will take four and five not equal and five is not close to six.

462
00:26:46,730 --> 00:26:48,050
So you will call one more time.

463
00:26:49,410 --> 00:26:55,330
One, two, three, four and five, the value of five now, so it reaches here.

464
00:26:55,920 --> 00:26:58,000
So this is your next and this is not possible.

465
00:26:58,230 --> 00:27:01,000
The value of an is five and you want to search for six.

466
00:27:01,380 --> 00:27:06,300
So now five equals five, eight ages and ages.

467
00:27:06,300 --> 00:27:08,350
And so in that case, I will return false.

468
00:27:08,400 --> 00:27:09,780
So I will return false.

469
00:27:10,200 --> 00:27:13,770
And whatever value you are getting from the equation, you are just likely returning.

470
00:27:14,040 --> 00:27:14,730
So I will return.

471
00:27:14,730 --> 00:27:15,510
False return.

472
00:27:15,510 --> 00:27:16,140
False written.

473
00:27:16,140 --> 00:27:16,800
False return.

474
00:27:16,800 --> 00:27:17,890
False return false.

475
00:27:18,180 --> 00:27:19,800
And finally, I will return false.

476
00:27:20,700 --> 00:27:23,920
Six is not present this idea that the output is false.

477
00:27:24,330 --> 00:27:25,520
So that's how it is working.

478
00:27:25,830 --> 00:27:28,740
So this approach passing the index.

479
00:27:28,770 --> 00:27:30,820
This is exactly like the for loop approach.

480
00:27:31,680 --> 00:27:33,570
This is exactly like the for loop approach.

481
00:27:34,360 --> 00:27:36,360
It is the same number of elements.

482
00:27:36,390 --> 00:27:37,980
Same exact same.

483
00:27:38,280 --> 00:27:39,870
Just only this condition.

484
00:27:41,050 --> 00:27:42,760
This is like a placeless.

485
00:27:44,110 --> 00:27:48,310
And this is the best case, and this is if the value founded on.

486
00:27:49,520 --> 00:27:50,880
So this is from this video.

487
00:27:50,930 --> 00:27:52,280
I will see you in the next one.

