All language subtitles for 4. Finding an Element within a List

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
hu Hungarian Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,210 --> 00:00:06,570 What is going on, guys, and in this video, what we are going to do is simply to write a function 2 00:00:06,570 --> 00:00:07,890 that returns true. 3 00:00:08,190 --> 00:00:15,060 If it has a node with the received value, otherwise it will return a false. 4 00:00:15,240 --> 00:00:22,800 So simply saying the function should receive a linked list and some individual number and the function 5 00:00:22,800 --> 00:00:26,820 should go through all the nodes of the list and return. 6 00:00:26,820 --> 00:00:29,820 True, if this number exists in the list. 7 00:00:30,120 --> 00:00:37,740 Otherwise, if it doesn't exist, if it doesn't exist, if it doesn't exist, we should return. 8 00:00:37,920 --> 00:00:39,420 We should return. 9 00:00:40,830 --> 00:00:41,340 False. 10 00:00:42,060 --> 00:00:45,890 OK, so either a true or either false. 11 00:00:46,620 --> 00:00:54,240 So this exercise is very similar to the exercise where we had to count how many nodes there are in the 12 00:00:54,240 --> 00:00:54,720 list. 13 00:00:55,650 --> 00:01:04,710 And this question, we also know that we have to do something similar and it is to iterate through the 14 00:01:04,710 --> 00:01:10,770 lists nodes and make comparison between the received number and the data. 15 00:01:10,830 --> 00:01:17,340 OK, the data field of each of the nodes, we are checking if there is a match, then we should return. 16 00:01:17,340 --> 00:01:18,680 True, otherwise false. 17 00:01:18,870 --> 00:01:20,700 And I think you got the point. 18 00:01:21,000 --> 00:01:28,050 And this video is being taught right after the previous video where I talked to and explained to you 19 00:01:28,050 --> 00:01:33,040 guys, what is the boolean data type and how you may also use it. 20 00:01:33,420 --> 00:01:39,390 So now that you know how to use a boolean data type, whether it's true or false, then in this case 21 00:01:39,390 --> 00:01:44,440 you will be able to use a Boolean function and boolean result. 22 00:01:44,730 --> 00:01:46,110 So here we go. 23 00:01:46,110 --> 00:01:52,070 We have our I hope the instructions are clear, OK, if something isn't clear, so pass the video and 24 00:01:52,170 --> 00:01:56,660 even ask any questions of this chapter. 25 00:01:56,670 --> 00:01:57,810 And what do we have here? 26 00:01:57,810 --> 00:02:00,360 Is the structure of node. 27 00:02:00,550 --> 00:02:01,060 OK. 28 00:02:01,450 --> 00:02:03,150 Nothing, nothing new here. 29 00:02:03,540 --> 00:02:06,000 And what we are going to do is to write a function. 30 00:02:06,360 --> 00:02:10,680 We know that the function returns or at least it should return a boolean type. 31 00:02:11,280 --> 00:02:17,490 So for that we will simply like include include just like a show to us, the D. 32 00:02:17,490 --> 00:02:20,760 Bool s, the standard boolean dot age. 33 00:02:21,210 --> 00:02:26,250 You know, what we are going to do is the type of the function is going to be bool, OK, because it's 34 00:02:26,250 --> 00:02:34,770 either a true or false if we would have specified here integer and then we know that there is a wide 35 00:02:34,950 --> 00:02:41,720 range of values that these function may return also positive, negative and so on. 36 00:02:41,910 --> 00:02:49,620 So we want to like to minimize the options to being only either true or either false. 37 00:02:49,920 --> 00:02:55,830 And the function is going to be is number in least. 38 00:02:55,900 --> 00:02:57,600 OK, that's the name of the function. 39 00:02:57,600 --> 00:02:58,560 Very descriptive. 40 00:02:58,560 --> 00:02:59,100 It should be. 41 00:02:59,340 --> 00:03:01,110 I hope it's pretty. 42 00:03:01,110 --> 00:03:02,700 OK is no enlace. 43 00:03:02,730 --> 00:03:03,040 OK. 44 00:03:03,300 --> 00:03:06,230 And what we are going to do is we are going to receive a list. 45 00:03:06,480 --> 00:03:14,100 OK, so node pointer header of the address of the first element of the head element of these particular 46 00:03:14,100 --> 00:03:22,050 list and some integer number that we are going to look for in all of the nodes elements in this list. 47 00:03:22,710 --> 00:03:29,400 OK, so next thing we are going to do in the body of the function is that we are going to initialize 48 00:03:30,600 --> 00:03:33,990 some answer, let's call it to be equal to false. 49 00:03:34,020 --> 00:03:39,860 So for example, boolean answer equals to false, OK, to false. 50 00:03:39,870 --> 00:03:45,360 And then what we are going to do is to iterate over all the elements of this list. 51 00:03:45,780 --> 00:03:50,010 So for that, let's create additional temp variable of type nodes. 52 00:03:50,010 --> 00:03:52,320 Star temp equals to had. 53 00:03:52,500 --> 00:04:00,900 This will be used for iterating over all the nodes and while temp next is longest temp next, that does 54 00:04:00,900 --> 00:04:04,500 not equals to now meaning we haven't. 55 00:04:04,590 --> 00:04:05,840 OK, we haven't. 56 00:04:05,850 --> 00:04:17,610 While we still have additional additional nodes to explore, while that's the case, we are going to 57 00:04:17,850 --> 00:04:26,910 see if a given a given a given node in the let's maybe instead of using templates use here at current 58 00:04:26,910 --> 00:04:28,740 node that we are exploring. 59 00:04:28,740 --> 00:04:38,460 So current node, current node, if the current node data, if its data is equal to Neme. 60 00:04:38,760 --> 00:04:47,850 So that means that we have found out that there is a node with the data of nums. 61 00:04:47,850 --> 00:04:55,510 So we found it out and we can say that answer equals two through in this case to true. 62 00:04:56,100 --> 00:04:59,250 And in this case we can also not. 63 00:04:59,320 --> 00:05:03,610 Return because I said that we should go through all the nodes. 64 00:05:03,740 --> 00:05:08,900 OK, so if we have to go through all the nodes, then that's OK. 65 00:05:08,920 --> 00:05:13,120 So let's use current node next. 66 00:05:13,390 --> 00:05:18,690 Equal to our current node equals to current node next. 67 00:05:18,940 --> 00:05:24,450 Just moving further, our current pointer in the case that we didn't find out. 68 00:05:24,460 --> 00:05:30,160 And finally, finally, finally, we will return the end of the answer, OK? 69 00:05:30,160 --> 00:05:32,340 Which is either true or false. 70 00:05:32,710 --> 00:05:38,410 And you may be asking yourself, why do we even need these bool answer equals to false in the first 71 00:05:38,410 --> 00:05:41,920 place and why didn't we return here? 72 00:05:41,960 --> 00:05:43,720 The answer once we found out. 73 00:05:43,730 --> 00:05:48,610 So we won't need to iterate even further and just to waste time. 74 00:05:48,610 --> 00:05:54,850 And you are right, 100 percent, guys, because I just wanted to show you, because the question was 75 00:05:54,850 --> 00:05:57,140 to go through all the nodes of the list. 76 00:05:57,160 --> 00:06:04,810 OK, so there is really no reason to go through the next nodes of the list once you found out that number 77 00:06:04,810 --> 00:06:07,040 exists in the digit of one of the nodes. 78 00:06:07,240 --> 00:06:12,390 So in this case, you may return answering to finish the execution of the function. 79 00:06:12,610 --> 00:06:20,860 And also there is actually no even reason to create this variable just for some convenience and explanation. 80 00:06:20,860 --> 00:06:21,700 I created it. 81 00:06:22,510 --> 00:06:30,700 Basically, what I would have done in this case is that if current node data equals equals dunam, so 82 00:06:30,700 --> 00:06:32,390 in this case, return true. 83 00:06:32,890 --> 00:06:33,500 OK. 84 00:06:33,520 --> 00:06:40,750 And otherwise, if we have reached OK, we are out of this while loop only if we reached the end of 85 00:06:40,750 --> 00:06:42,730 the of the list. 86 00:06:42,810 --> 00:06:45,440 OK, and we didn't return through so far. 87 00:06:45,700 --> 00:06:53,440 So definitely the answer would be that now we have to return false because we didn't find we did not 88 00:06:53,440 --> 00:07:00,790 find the answer and num in any of the nodes in this list. 89 00:07:00,970 --> 00:07:02,980 So I hope that's clear to you guys. 90 00:07:03,010 --> 00:07:06,440 So once again, let's go over all the steps we've done here. 91 00:07:06,460 --> 00:07:13,060 We received the head of the of the list and we received some number and we wanted to go over all the 92 00:07:13,060 --> 00:07:19,900 elements of this linked list and to see if a given number, some arbitrary number that the user sends, 93 00:07:20,530 --> 00:07:28,300 if this number, the function receives, if it is inside of some of the nodes in this list, if that's 94 00:07:28,300 --> 00:07:30,130 the case, this function should return. 95 00:07:30,130 --> 00:07:30,580 True. 96 00:07:30,590 --> 00:07:33,910 And if it's not, then the function should return false. 97 00:07:34,180 --> 00:07:38,150 And when we are going to call this function, it's going to be pretty much nice. 98 00:07:38,210 --> 00:07:45,000 We are going to ask if he's numbering list and pass the list and a number and we will receive through. 99 00:07:45,010 --> 00:07:50,650 If that's the case, if the number is inside of this list, otherwise we will receive false. 100 00:07:50,770 --> 00:07:56,380 And based on this result, we will be able to, I don't know, to make some operations, seem to make 101 00:07:56,380 --> 00:08:00,740 some conclusions and based on that, to execute different parts of code. 102 00:08:01,180 --> 00:08:02,590 So thank you, guys. 103 00:08:02,740 --> 00:08:04,390 And I hope this video is clear. 104 00:08:04,390 --> 00:08:11,260 If you ask me any questions about it, if you have and until next time, I'll see you then. 10254

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