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
What is going on, guys, and in this video, what we are going to do is simply to write a function
that returns true.
If it has a node with the received value, otherwise it will return a false.
So simply saying the function should receive a linked list and some individual number and the function
should go through all the nodes of the list and return.
True, if this number exists in the list.
Otherwise, if it doesn't exist, if it doesn't exist, if it doesn't exist, we should return.
We should return.
False.
OK, so either a true or either false.
So this exercise is very similar to the exercise where we had to count how many nodes there are in the
list.
And this question, we also know that we have to do something similar and it is to iterate through the
lists nodes and make comparison between the received number and the data.
OK, the data field of each of the nodes, we are checking if there is a match, then we should return.
True, otherwise false.
And I think you got the point.
And this video is being taught right after the previous video where I talked to and explained to you
guys, what is the boolean data type and how you may also use it.
So now that you know how to use a boolean data type, whether it's true or false, then in this case
you will be able to use a Boolean function and boolean result.
So here we go.
We have our I hope the instructions are clear, OK, if something isn't clear, so pass the video and
even ask any questions of this chapter.
And what do we have here?
Is the structure of node.
OK.
Nothing, nothing new here.
And what we are going to do is to write a function.
We know that the function returns or at least it should return a boolean type.
So for that we will simply like include include just like a show to us, the D.
Bool s, the standard boolean dot age.
You know, what we are going to do is the type of the function is going to be bool, OK, because it's
either a true or false if we would have specified here integer and then we know that there is a wide
range of values that these function may return also positive, negative and so on.
So we want to like to minimize the options to being only either true or either false.
And the function is going to be is number in least.
OK, that's the name of the function.
Very descriptive.
It should be.
I hope it's pretty.
OK is no enlace.
OK.
And what we are going to do is we are going to receive a list.
OK, so node pointer header of the address of the first element of the head element of these particular
list and some integer number that we are going to look for in all of the nodes elements in this list.
OK, so next thing we are going to do in the body of the function is that we are going to initialize
some answer, let's call it to be equal to false.
So for example, boolean answer equals to false, OK, to false.
And then what we are going to do is to iterate over all the elements of this list.
So for that, let's create additional temp variable of type nodes.
Star temp equals to had.
This will be used for iterating over all the nodes and while temp next is longest temp next, that does
not equals to now meaning we haven't.
OK, we haven't.
While we still have additional additional nodes to explore, while that's the case, we are going to
see if a given a given a given node in the let's maybe instead of using templates use here at current
node that we are exploring.
So current node, current node, if the current node data, if its data is equal to Neme.
So that means that we have found out that there is a node with the data of nums.
So we found it out and we can say that answer equals two through in this case to true.
And in this case we can also not.
Return because I said that we should go through all the nodes.
OK, so if we have to go through all the nodes, then that's OK.
So let's use current node next.
Equal to our current node equals to current node next.
Just moving further, our current pointer in the case that we didn't find out.
And finally, finally, finally, we will return the end of the answer, OK?
Which is either true or false.
And you may be asking yourself, why do we even need these bool answer equals to false in the first
place and why didn't we return here?
The answer once we found out.
So we won't need to iterate even further and just to waste time.
And you are right, 100 percent, guys, because I just wanted to show you, because the question was
to go through all the nodes of the list.
OK, so there is really no reason to go through the next nodes of the list once you found out that number
exists in the digit of one of the nodes.
So in this case, you may return answering to finish the execution of the function.
And also there is actually no even reason to create this variable just for some convenience and explanation.
I created it.
Basically, what I would have done in this case is that if current node data equals equals dunam, so
in this case, return true.
OK.
And otherwise, if we have reached OK, we are out of this while loop only if we reached the end of
the of the list.
OK, and we didn't return through so far.
So definitely the answer would be that now we have to return false because we didn't find we did not
find the answer and num in any of the nodes in this list.
So I hope that's clear to you guys.
So once again, let's go over all the steps we've done here.
We received the head of the of the list and we received some number and we wanted to go over all the
elements of this linked list and to see if a given number, some arbitrary number that the user sends,
if this number, the function receives, if it is inside of some of the nodes in this list, if that's
the case, this function should return.
True.
And if it's not, then the function should return false.
And when we are going to call this function, it's going to be pretty much nice.
We are going to ask if he's numbering list and pass the list and a number and we will receive through.
If that's the case, if the number is inside of this list, otherwise we will receive false.
And based on this result, we will be able to, I don't know, to make some operations, seem to make
some conclusions and based on that, to execute different parts of code.
So thank you, guys.
And I hope this video is clear.
If you ask me any questions about it, if you have and until next time, I'll see you then.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.