All language subtitles for 13. Finding Maximum Value in a Sequence of Elements (Using Recursion)

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

What is going on, ladies and gentlemen, this exercise, what we are going to do is simply to write

a function, a recursive one that will get some number.

OK, so recursive function, right?

Because we are at a recursive section recursions.

So recursive function that will get that will get some on natural.

No, let's say no.

OK, and this function will receive, you will receive OK and read a sequence, read a sequence of no

numbers from the user.

And finally this function should the return return of the maximum value in the sequence.

OK, guys, so recursive function to get some r some num values from the user, a sequence of num values

from the user and basically to return the maximum.

So take a few moments, think about how these can be solved.

OK, basically I know that some of you may be thinking to yourself like and find marks and get some

number and then simply to use like I don't know while let's define basically while and arm is greater

than let's say.

Then zero, then in this case, simply use some kind of function and read and return the maximum.

OK, so this will be right and these will probably solve it if you are going to use the territory approach.

But nevertheless, we are using here and we need to create a recursive function because that's basically

the instructions for this exercise.

So and find mux in some of these signature is all right.

We are not going to use the wild things here, but we are going to make some basic condition and we

are going to make some recursive calls.

OK, so take a few moments, think about how it can be solved.

And once you're back, we are going to continue and solve it together.

So that's actually not a very easy task.

OK, because you see this exercise is not considered to be so trivial.

So what I recommend you when you start working on these exercises is basically to start with some example.

So let's say let's say none will be equal to three.

And the sequence is going to be like one three into OK, that's going to be the sequence.

So what do you have to do?

I think that the best approach is simply to start with some drawing.

OK, so we know that probably that's going to be the case.

OK, so one, two, three and let's say four.

OK, so that's going to be the case.

And we know that we have to like to first of all, to call this function for number equals to three

now equal to two.

Now I'm equal to one, and that's basically, I don't know, now equal to zero, which is does which

does not satisfy the base condition of the base condition is false.

OK.

All right, and now what do we have to do simply to read some input here?

OK, here will be an input from the user and here will also be an input from the user.

And also here will be some input from the user.

And we have finally, finally the final result.

We have to return.

The maximum.

OK, so we need to make like to make sure that we understand that we understand how to compare between

these different inputs.

So let's say that's input A, B and C and so on.

There may be also D, E, F and so on and so forth.

So we need to think of some way of how we can compare between.

Are the previous input to the current input and basically to every time that we return from a recursions

or for example, we are going to return accuracy because that's the maximum.

But from here to here, we are going to return the maximum between B and the maximum so far.

And from here, we are going to return the maximum between an input A and the maximum received so far.

OK, so that's very important to take into consideration the fact that we want to like to take into

account the maximum.

The maximum.

Value.

So far, OK, so that's also very important.

So how should you solve it?

How should we basically treat this exercise?

So basically, let's start and talk about the base condition, OK?

And the base condition is going to be as long as numb is greater than one, right?

As long as that's the case, because we know that we want just the sequence of numb numbers are received

from the user.

And every time we are simply going to like to decrease it by one and make the recursive call.

So if that's the case, then what we have to do, what do we have to do?

We have to create additional variable and let's call it blocks so far.

OK, this variable, OK, this variable will be used to check OK to check into received the value of

just go down a little bit.

OK, so that everything will be seen so much so far will be equals to find marks for now minus one.

And what do I mean by that.

OK, let me just a little bit.

Erase it.

OK, what do I mean by that, basically marks so far will be the maximum received so far from the previous

recursion calls.

OK, and also what these find marks is going to return.

It also has to receive some input from the user.

Right.

So let's get some input, user user input, you user input.

And now let's bring some nice message to the screen.

So primitive enter into an input.

Scan a scan of percentage and read this important story inside of the variable user input.

And now once we have the user input and we have the mux values, so far, what we have to do is simply

to ask the following question.

If the user input in this case in these are recursive function call is greater than maximum value so

far.

So if that's the case, then what should we return from this function?

We should return the user input because that's the maximum so far from this point.

And if not, we are going to return what the maximum value so far received in the previous calls.

OK, so is it clear to you guys?

Do you see this picture?

Do you see how it basically looks like?

So if none is greater than one, then that's what happens.

All right.

And one of the main questions that we haven't solved yet, but I think that we will right away let's

start and basically run this example together.

So for that, let us use our amazing pen.

So for a number equal to three, we get an input of one.

OK, so that's the input of one.

And then we will ask Max so far, find Max.

OK, so we go here.

We read again the input and the input is three, OK, and then we call the max so far for these function,

we don't know it yet.

Right.

We don't know the value of Max so far because it's going to be received from this function and this

function does not know also the max so far until this point.

So it's going also to be received from fine max for one.

And this one doesn't know either Max so far and is going to receive it from this one.

OK, the value here is to and here we know that that of a user input is going to be what?

What it's going to be, it's not going to we are going to read any input from the user, but the question

is if that's also OK, what do you think guys want?

What happens here is this condition.

Take a few moments, a few minutes even to think about it is this condition is OK.

If none is greater than one, then will we reach even in the first place to this now equals to the zero.

What do you think?

What do you think guys?

And of course, the solution is definitely not because this condition will never reach these now equals

to zero, since this if none is greater than one, OK, will not be applied on this one because none

equals to one and it's not greater to one than in this case.

We will not ask for marks so far.

OK, so that's something we can remove.

OK, so the stubborn condition, the base condition is a little bit different than what I've drawn here.

And the reason is very simple because I wanted you to think of the solution and to understand the base

case, the actual base case and the actual base case is once we reach the final input.

OK, so once we reach the final input, which is this one in this case, OK, that's the final input,

OK.

The last input from the user in the last input, we know that the maximum so far until this point is

basically just the value of the input.

Right.

Because there are no any recursive calls after that.

So that's why we have the final input as the value of two.

And what we have to return this condition is false.

So nothing will be returned?

No, of course not.

But we know that the maximum so far that should be returned is just the user input in this case.

OK, so what will happen next?

OK, once we go back, so from this recursive call, we return the user input because this condition

was not true.

So Mark so far will be to in this case.

And then we ask if user input is greater and is greater than the mark so far in this case, return the

user input.

So here we are going through a three in here.

In this instance, we are going to check it out again.

And to see if three is less than half the mark so far is less than user input.

If that's the case, we are going to what we are going to basically Mark so far here is greater than

the user input.

Now, that's why we are going to return three as the final result.

So very important to understand all of these concepts, guys, all of these steps.

This exercise is not an easy one.

It's not straightforward.

OK, try to write also by yourself a few examples.

Try to think about it, how you should call it.

Why is this?

The condition is exactly as it is trying maybe to think also if there are maybe some other solutions

that may come to your mind and.

Basically, what I suggest may be maybe, maybe let me think about it.

Mm hmm.

Maybe in the next exercise, just to make everything more clear and as clear as possible to you in the

next exercise, once you practice this one also on your own, in the next exercise, we are going also

to find the minimum.

OK, so instead of finding the maximum, we are going to find the minimum.

But the importance in the next exercise is that you will try again to do it on your own and to make

sure that it works by running.

Also some void mean and with a couple of scenarios and to see that everything works exactly as you expected.

So thank you guys for watching.

My name is Vlad.

This is Alphatech.

I'm really enjoying teaching you these very amazing material that may help you in your studies, whether

you're a student, I don't know, in school, in college and university, or basically you're just the

self employed or C programming developer.

That's also an option.

And yeah, I hope you like it.

And I'll see you in the next videos.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.