All language subtitles for 10. Good Multiplication Neighbors

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,520 --> 00:00:06,480 All right, what is going on, ladies and gentlemen, and in this video, we are going to solve some 2 00:00:06,480 --> 00:00:10,770 interesting exercise regarding our work with neighbors. 3 00:00:11,430 --> 00:00:17,460 So we have to do now is just the basic exercise, using a raise and using some conditions. 4 00:00:18,450 --> 00:00:24,900 And what we are required to do is to write a program that creates an array of integers. 5 00:00:25,200 --> 00:00:27,780 So that would be our first step. 6 00:00:28,440 --> 00:00:34,860 And the program should check and print of the array has at least one element with good neighbors. 7 00:00:35,400 --> 00:00:41,370 And of course, the definition for good neighbors can be like really different. 8 00:00:41,370 --> 00:00:48,900 Right, because there may be good neighbors that I don't know does not do not make noise after, I don't 9 00:00:48,900 --> 00:00:57,480 know, 10:00 p.m. and there may be like other neighbors that are simply kind people and they say good 10 00:00:57,480 --> 00:00:58,770 morning and good night. 11 00:00:59,430 --> 00:01:04,080 And also there may be other neighbors as well. 12 00:01:05,190 --> 00:01:11,790 And basically in this exercise, what we have to do is simply to define what is a good neighbor and 13 00:01:11,790 --> 00:01:13,290 basically a good neighbor. 14 00:01:14,370 --> 00:01:20,670 And an array with a good neighbor sees an array that has at least one element with good neighbors has 15 00:01:20,670 --> 00:01:27,620 a value that equals to the multiplication of both of its neighbors on their right and on the left. 16 00:01:28,200 --> 00:01:35,520 And I think the best idea, the best option to explain it is simply to watch these exercise, watch 17 00:01:35,520 --> 00:01:36,780 these two examples. 18 00:01:37,860 --> 00:01:44,310 So we said that an array with good neighbors is considered to be an array that has at least one element. 19 00:01:44,490 --> 00:01:50,280 That is the multiplication they think its value equals to the multiplication on the of the element on 20 00:01:50,280 --> 00:01:53,290 their left and of the element on the right. 21 00:01:53,700 --> 00:01:59,730 So in this case, we know that we ask the question, does three equals to one multiplied by two? 22 00:02:01,290 --> 00:02:07,170 And if that's the case, then this array can be considered is array that has good neighbors. 23 00:02:07,470 --> 00:02:12,540 But in this case, that's not the answer to this, not the question yet, because three does not equal 24 00:02:12,540 --> 00:02:14,100 to one multiplied by two. 25 00:02:14,500 --> 00:02:21,540 So then we go to the next element and we ask two, does it equal two equals two three multiplied by 26 00:02:21,540 --> 00:02:22,000 six? 27 00:02:22,140 --> 00:02:23,940 No, of course the answer is no. 28 00:02:24,250 --> 00:02:31,590 Then we move on to the next element and we ask, does six equals two the multiplication between two 29 00:02:31,590 --> 00:02:32,130 and three? 30 00:02:32,400 --> 00:02:33,780 Yes, that's the case. 31 00:02:34,770 --> 00:02:37,500 Six equals to two multiplied by three. 32 00:02:37,920 --> 00:02:44,460 Then in this case, we can say absolutely that this array has good neighbors, OK, because it has at 33 00:02:44,460 --> 00:02:52,020 least one element that its value equals to the multiplication between the element on its left and the 34 00:02:52,020 --> 00:02:53,300 element on its right. 35 00:02:54,060 --> 00:03:01,020 And if we will take a look at the second example, we will see that there is no element that satisfies 36 00:03:01,020 --> 00:03:07,980 this condition, that the multiplication of the right and left elements gives basically the value of 37 00:03:07,980 --> 00:03:09,000 the given element. 38 00:03:10,030 --> 00:03:10,940 OK, awesome. 39 00:03:10,990 --> 00:03:17,350 So that's basically are the instructions for this exercise and now what we have to do is simply to start 40 00:03:17,350 --> 00:03:18,240 implementing it. 41 00:03:18,730 --> 00:03:25,720 So let us start and the first thing that we have to do is just use the following call. 42 00:03:25,810 --> 00:03:26,440 It's create. 43 00:03:26,490 --> 00:03:29,410 And I know my array of size. 44 00:03:29,410 --> 00:03:29,920 I don't know. 45 00:03:29,920 --> 00:03:37,330 Let's make it five and let's of course, we can use some functions to read the input from the user. 46 00:03:37,540 --> 00:03:39,390 But yeah, also we can do that. 47 00:03:39,730 --> 00:03:41,950 So in my array of size five. 48 00:03:43,540 --> 00:03:43,960 Yeah. 49 00:03:44,020 --> 00:03:45,240 So let's go like this. 50 00:03:45,250 --> 00:03:52,990 So pretty def basically also I for I equals to zero. 51 00:03:52,990 --> 00:03:57,070 I have less than five Ibos plus course. 52 00:03:57,230 --> 00:04:02,860 The value and the size of the array could have been defined using the defined structure here or something 53 00:04:02,860 --> 00:04:06,970 like that to define size font size five. 54 00:04:08,110 --> 00:04:12,180 But yeah let's, let's also use the size here. 55 00:04:12,190 --> 00:04:13,240 No problem with that. 56 00:04:13,540 --> 00:04:16,030 It's simply the same as we've written five. 57 00:04:16,060 --> 00:04:16,420 Right. 58 00:04:17,460 --> 00:04:17,910 Awesome. 59 00:04:17,920 --> 00:04:26,350 So now let's read the information from the users or print out enter value percentage be OK and then 60 00:04:26,350 --> 00:04:27,790 the user is going to enter. 61 00:04:27,790 --> 00:04:36,280 His value is going to be like what value to be plus one enter value one, value two and so on. 62 00:04:36,280 --> 00:04:40,360 And now you can have percentage the installed inside. 63 00:04:40,840 --> 00:04:46,290 Inside where my error are it index what index site excite. 64 00:04:47,320 --> 00:04:51,340 So make sure you don't really mess up at this step ok. 65 00:04:51,380 --> 00:04:57,010 When you read the information from the user and store it inside the arrays elements. 66 00:04:57,190 --> 00:04:58,900 OK, that's also very important. 67 00:04:59,800 --> 00:05:00,210 Awesome. 68 00:05:00,220 --> 00:05:06,880 So this step is over and now we have to basically once we've read the information and we've constructed 69 00:05:08,140 --> 00:05:16,390 the array from the user, what do we have to do is simply to implement these logic of the good neighbors 70 00:05:17,080 --> 00:05:18,700 and how should we do that? 71 00:05:19,000 --> 00:05:20,350 How should we do it? 72 00:05:20,980 --> 00:05:27,820 So we said that we have this array and we are interested in finding the. 73 00:05:27,820 --> 00:05:32,650 And what are we interested in finding the neighbors, the multiplication of the neighbors. 74 00:05:33,340 --> 00:05:39,010 And one of the things here is basically to understand that for every element that we are going to check, 75 00:05:39,310 --> 00:05:47,470 it's very important to make sure that we are we do we check both of its elements, let's say at index. 76 00:05:47,470 --> 00:05:52,470 I end at the index in minus one and at index I plus one. 77 00:05:53,050 --> 00:05:56,830 OK, so an element on the left and the element on the right. 78 00:05:58,000 --> 00:06:01,240 But the main question comes here basically what should be the boundaries? 79 00:06:01,240 --> 00:06:09,100 Because this element, as well as this element, they are basically on the corners of this array and 80 00:06:09,100 --> 00:06:13,820 they don't have either the left or neighbor or the right neighbor. 81 00:06:14,410 --> 00:06:22,090 So in this case, we know that they are out of limits as well, because we simply if we would have checked 82 00:06:23,590 --> 00:06:29,110 the multiplication between are neighbors and we would have tried to access this place, he does not 83 00:06:29,110 --> 00:06:33,550 belong to the array and also maybe does not also belong to the program. 84 00:06:33,880 --> 00:06:36,880 And then you will simply get some access violation. 85 00:06:37,420 --> 00:06:42,770 And that's not something that we want to do because that also doesn't make any sense. 86 00:06:44,260 --> 00:06:44,830 All right. 87 00:06:46,510 --> 00:06:56,530 Now, let us try to run the loop, so for and with watching this, should we start, I suggest to start 88 00:06:56,530 --> 00:06:57,460 with index one. 89 00:06:57,580 --> 00:06:58,570 And why is that? 90 00:06:58,570 --> 00:07:02,830 Because the index one is the second element in our programming language. 91 00:07:03,430 --> 00:07:08,910 And we said that the leftmost element, the first element is not something that we want to start with. 92 00:07:09,380 --> 00:07:14,170 OK, so I equals to one as long as I is less than size. 93 00:07:14,320 --> 00:07:15,580 OK, I plus plus. 94 00:07:16,180 --> 00:07:22,840 So my question is, do you think that this condition of as long as I is less than size is OK because 95 00:07:22,840 --> 00:07:29,890 I mean these three are these loop will be executed as long as I is less than five. 96 00:07:29,890 --> 00:07:35,920 Meaning for I equals two for this loop should also be executed and it should check the element on the 97 00:07:35,920 --> 00:07:38,930 left as well as the element on the right. 98 00:07:39,730 --> 00:07:43,090 So if you would have taken a look at this one. 99 00:07:43,240 --> 00:07:50,920 OK, so this value is at index four because index zero, index one, index two, index three and index 100 00:07:50,920 --> 00:07:52,320 for them. 101 00:07:52,450 --> 00:07:56,920 These value alignment would we said that we do not want to check it out. 102 00:07:56,920 --> 00:08:05,080 So that's why we will say as long as I is less than size minus one, not taking into account the last 103 00:08:05,080 --> 00:08:06,340 element in this array. 104 00:08:07,420 --> 00:08:07,900 All right. 105 00:08:07,900 --> 00:08:11,680 So now let us ask a simple question. 106 00:08:12,100 --> 00:08:13,900 You know, this question goes like this. 107 00:08:13,930 --> 00:08:27,100 If if my error, OK, at Index I equals to my error it index I plus or minus one, the index on the 108 00:08:27,100 --> 00:08:34,390 left, the value on the left multiplied by my Iran it index plus one, the value on the right. 109 00:08:34,840 --> 00:08:43,270 Then if that's the case then what we should do is simply to print that this array that this array has 110 00:08:43,270 --> 00:08:47,070 good neighbors, basically something like that, something like this message. 111 00:08:47,620 --> 00:08:55,640 So let's do it like this are this array has good neighbors. 112 00:08:55,850 --> 00:08:57,060 Neighbours. 113 00:08:57,190 --> 00:09:00,550 Yeah, this array has good neighbours. 114 00:09:02,170 --> 00:09:07,920 And one question that I'm going to ask you here is, what do you think should happen now? 115 00:09:07,930 --> 00:09:15,910 Should basically we leave it as is or maybe you have an idea of something that we can add to make this 116 00:09:15,910 --> 00:09:17,840 problem even better? 117 00:09:17,890 --> 00:09:23,680 OK, but so far, if you have any questions, feel free to stop the video and ask them, OK, I'll do 118 00:09:23,680 --> 00:09:26,530 my best to answer any of your questions. 119 00:09:26,650 --> 00:09:35,500 Maybe if you know and if you see students that are struggling OK and they have questions that for some 120 00:09:35,500 --> 00:09:38,860 reason are on answer, feel free to answer them. 121 00:09:38,860 --> 00:09:42,190 That's also part of the learning process to help one another. 122 00:09:42,460 --> 00:09:50,080 And that's how you are getting better and better in programming while also answering other people questions 123 00:09:50,080 --> 00:09:51,220 and discussions. 124 00:09:52,210 --> 00:09:59,350 OK, so if we will live in this way, OK, and we will have at least more than just one element, then 125 00:09:59,380 --> 00:10:01,090 these are message. 126 00:10:01,720 --> 00:10:08,020 If we will have more than just one element with that satisfies the condition of having good neighbors, 127 00:10:08,350 --> 00:10:11,950 then this message will be printed, I don't know, five, 10, 15 times. 128 00:10:12,070 --> 00:10:13,320 Right, maybe. 129 00:10:14,200 --> 00:10:16,080 And that's not something that we want. 130 00:10:16,330 --> 00:10:22,540 Also, what we don't want is to spend any resources once we found out that this condition happens to 131 00:10:22,540 --> 00:10:23,050 be true. 132 00:10:23,330 --> 00:10:29,680 OK, so, I mean, if this condition happens to be true, then there is no reason to pretend to continue 133 00:10:29,680 --> 00:10:38,380 executing this loop because otherwise how if this condition is not true, how will be will we be even 134 00:10:38,380 --> 00:10:41,660 able to print this array does not have good neighbors. 135 00:10:41,760 --> 00:10:45,280 OK, so that's another message that we have to take care of. 136 00:10:46,720 --> 00:10:51,970 So one of the things that may be used here is simply to use a flag. 137 00:10:52,000 --> 00:10:57,880 OK, I don't know, something like that and has good neighbors. 138 00:10:58,750 --> 00:11:03,310 And this flag will be one assuming that they are good neighbors. 139 00:11:03,430 --> 00:11:06,970 OK, or let's assume that or has good neighbors. 140 00:11:06,970 --> 00:11:11,150 Now, we will assume that before these, Iraq does not have good neighbors. 141 00:11:11,170 --> 00:11:20,950 OK, so assumption assumption Ray does not have does not have good neighbors. 142 00:11:22,060 --> 00:11:23,020 Doesn't really matter. 143 00:11:23,030 --> 00:11:27,340 We can solve it with two ways, but let's think with this one. 144 00:11:27,380 --> 00:11:34,090 OK, so if that's the case, ok, then we can say that has good neighbors will be equal to one. 145 00:11:34,270 --> 00:11:41,020 OK, this flag will specify basically that we found out at least one element that satisfies the condition 146 00:11:41,020 --> 00:11:42,940 of having good neighbors. 147 00:11:43,480 --> 00:11:48,940 And in this case, what we will use is just setting of this flag. 148 00:11:48,940 --> 00:11:55,780 That array has good neighbors, OK, has good neighbors. 149 00:11:56,140 --> 00:11:56,670 Awesome. 150 00:11:58,000 --> 00:12:01,300 And also what I suggest is to add these brake line. 151 00:12:01,480 --> 00:12:09,100 OK, so there are so that if we have, like, I don't know, large arrays and so on, that these operations 152 00:12:09,100 --> 00:12:14,230 will not go any further because we found out that this array has good neighbors. 153 00:12:14,800 --> 00:12:15,250 Awesome. 154 00:12:15,820 --> 00:12:23,260 And outside of these for a loop, we can ask a simple question if his neighbors equals to zero, right. 155 00:12:23,870 --> 00:12:28,630 If he has good neighbors, flag equals to zero. 156 00:12:28,960 --> 00:12:35,500 Letting these guys bring F print f what should we print? 157 00:12:36,040 --> 00:12:46,960 This array does not have any good neighbors, any good, good neighbors. 158 00:12:51,100 --> 00:12:51,640 Awesome. 159 00:12:52,480 --> 00:12:57,010 So maybe you guys are maybe maybe maybe. 160 00:12:57,340 --> 00:13:02,260 I'm just saying maybe there are a couple of options to solve this exercise. 161 00:13:02,260 --> 00:13:04,450 OK, that's one of them. 162 00:13:04,750 --> 00:13:06,640 OK, that's one of them. 163 00:13:06,910 --> 00:13:07,250 Oh. 164 00:13:07,750 --> 00:13:13,360 Another option may also be like to move this message out of here also too. 165 00:13:13,360 --> 00:13:17,710 I'm just going to show you now a couple of options that I can think of. 166 00:13:17,710 --> 00:13:18,310 Probably. 167 00:13:18,310 --> 00:13:18,640 Yeah. 168 00:13:19,570 --> 00:13:21,410 That basically will look like this. 169 00:13:21,430 --> 00:13:29,200 Or else if he has good neighbors equals to one, then in this case print this message. 170 00:13:30,220 --> 00:13:33,400 OK, so that's the other way around. 171 00:13:34,240 --> 00:13:37,150 Third way can be like this to you. 172 00:13:37,150 --> 00:13:39,040 Leave it as it was previously. 173 00:13:39,580 --> 00:13:41,110 Let's think about it. 174 00:13:41,110 --> 00:13:43,330 I don't know, maybe something like that. 175 00:13:43,840 --> 00:13:44,460 Where is it. 176 00:13:44,680 --> 00:13:45,340 What happened. 177 00:13:45,460 --> 00:13:46,740 Oh sorry. 178 00:13:47,860 --> 00:13:51,090 We were like here, right. 179 00:13:51,100 --> 00:13:51,430 Yeah. 180 00:13:51,760 --> 00:13:55,000 So another option is simply to use it like this. 181 00:13:55,900 --> 00:14:04,900 So remove this if condition, leave these print as a default, OK, is a default in here instead of 182 00:14:04,900 --> 00:14:11,680 the brake, which is the return zero because we know that also the main also function. 183 00:14:12,130 --> 00:14:19,810 And if these returns zero will be executed, then the program should stop right from here, right after 184 00:14:19,810 --> 00:14:20,320 this line. 185 00:14:20,440 --> 00:14:29,380 OK, and these lines will only be executed only if this array does not have any good neighbors. 186 00:14:30,340 --> 00:14:34,870 Of course, there are also like base cases that can be taken care of you. 187 00:14:34,870 --> 00:14:37,420 The array has one element and so on and so forth. 188 00:14:37,660 --> 00:14:43,990 But I'm not jumping into it because I don't think it's it's mandatory at this point. 189 00:14:45,430 --> 00:14:46,270 So, yeah. 190 00:14:46,270 --> 00:14:49,150 Guys, thank you so much for watching. 191 00:14:49,300 --> 00:14:50,500 Keep on practicing. 192 00:14:50,620 --> 00:14:51,670 Let me know what you think of. 193 00:14:51,730 --> 00:14:59,260 This video, and of course, so far, your review and your participation is really of great importance 194 00:14:59,260 --> 00:15:03,120 for me, it helps me a lot and it helps other students as well. 195 00:15:03,520 --> 00:15:04,680 So thank you so much. 196 00:15:04,690 --> 00:15:05,800 And until next time. 197 00:15:05,800 --> 00:15:06,810 My name is Vlad. 198 00:15:06,850 --> 00:15:08,320 This is Alphatech Academy. 199 00:15:08,320 --> 00:15:09,280 And I'll see you then. 19141

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