Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So what is going on, guys?
And welcome back to another very interesting video in our programming course.
And in the previous video, we started to talk and we also did some example regarding a recursive function
that all it had to do is just to get some natural number, which was knowm in this case to read a sequence
of numbers from the user.
OK, so basically a sequence of NUM numbers and then the function should return the maximum value in
this sequence.
And as we said previously, this can be done simply by using some for a loop and that's it.
But we need it and we solved it using the recursive approach by writing a recursive function.
And in this video, what we are going to do is simply to modify a little bit this question, and instead
of returning the maximum value, we will return the minimum value.
All right.
So that's not a big deal.
But still, I want to like to go over this exercise together.
So I've left also that template of the solution of the previous solution.
And we are just going to modify a couple of things and to make sure that we understand once again the
whole concept and the whole process of solving this exercise using recursion functions.
So with that being said, let's start working.
OK, so basically let's just modify the previous.
So so if we have this example of equal to equals to three and we have this sequence of one, three,
two in this example.
So now basically defined main function should return the value of one because that's the most the minimum
value in this sequence.
So let's first of all modify these find marks to be find mean and we will have also int num and now
we will simply also modify the variables names so minimal so far and the user input, user input is
going to remain the same in what we are going to do is just also modify it here.
So minimum so far, find minimum for now, minus one in minimum so far and know basically about that.
I want to talk to you guys.
OK, so.
OK, what do we want to do?
Basically, we want to write this function to be.
To have some some general structure, that's all it will be able to do is to find the minimum for a
given sequence of numbers that it's going to read from the user.
So if we have three numbers, these find mean for the value of three will be able to find the minimum
value in a sequence of three numbers.
Then in a recursive call, we are going to call these function again, find meaning with the value of
two.
And then we will assume that the function find men will be able to find the minimum value between the
two.
And as we said also previously.
Again, that's very important for you to maybe to write it down, I don't know, make some note or whatever
guys you're working with.
Basically, the base case is for this function find mean for economic woes to one.
That means that we want to find the minimum, OK, when we have a sequence of just one number and that's
the base case using these recursion function.
And if we know that we if we have just one number, then definitely this number in this sequence, which
is the user input, that's definitely the number that is going to be returned.
OK.
Awesome.
So that's also something that I wanted to say in the previous video, but I decided that I will edit
in this one.
So the approach was like this.
We are making some function.
If we are talking about the previous video, we had like find marks for a given name.
So basically, if we will generalize the function or functionality it can get, the previous function
can get some number, OK, which will represent a sequence that this function will be able to return
the maximum value or like in this case, in our current exercise, it will be able to return the minimum
value.
All right.
Awesome.
So now.
What we have to do is basically to go with pretty much the same approach and ask the following question,
we are looking for the minimum.
So far, so minimal, so far equals to find minimum.
So far, that's not a problem.
That's something that we we've done also previously.
And now we are going just probably to add these conditions.
So if the user input is less than the minimum so far.
OK, so if that's the case, if the current input is less than the minimum so far received from the
user in this sequence, then in this case we will return the user input and otherwise we will return
the minimum so far.
OK, so that's basically it for what I wanted to show you for this exercise.
Let's maybe build and run it to see and to make sure that everything works pretty much as we expected.
So let's go and build and run it building run so into a number three.
So a will.
What happened, what happened up?
We didn't call the function, so let's just call the function.
What's its name find mean.
So find me and then we will specify the number which these cases num let's build and run it once again.
So enter number three, you now enter an input.
So we said what was it in this example.
One, two, three, two, so one, three and two.
And we expect that this function, using this recursive approach, recursive manner will return the
value of one since this value is the most at the minimum.
OK, awesome.
So presenter and then what happened?
Oh, nothing happened because we didn't read the result.
Sorry you guys basically let's do it like end resolved so resolved equals to find mean so let's build
and run it.
So build and run it into a number three, enter a number three, one, three and two.
And what happened at the end printed this video.
Is something OK because.
The minimum value equals to the problem when you take some some exercise and you want to like to modify
one thing into running to make sure that everything is understandable, but not going into all the details.
So a lot of times things get messed up.
So enter a number.
Hopefully this one will work.
So three, one, three and two and the minimum value equals to one.
So basically, this is it for these video guys.
I hope you like it.
I hope you found it very, very useful.
Make sure you can write this function on your own.
Keep on practicing.
And we are going to see each other in the next videos.
Until then, bye bye.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.