All language subtitles for 21. Swap 2 Array Values One-by-One

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

Original subtitles

What is going on, beautiful people, what is going on, ladies and gentlemen, and in this video,

what we are going to do is simply to write a function and some sort of a program to test the doubt that

will receive to a race of the same size.

OK, so the function is going to receive to erase all of the same size.

And then what the function is going to do is simply to swap between each and any of the values of these

to erase.

So swap between their values, between their values, just one by one.

OK, and the time complexity of this thing is going to be O of end.

OK, so basically M represents the size of the array.

So we are simply going to iterate over both of these arrays and simply do swap between the values of

each and any of them.

So for that one we have to do is simply and I just make sure that you understand these ofin because

we are going to do it in just one operation or a couple of operation, but not is the size of the array

specifies in the next video.

So for now, what we are going to do is simply to define size and we are going to define some size,

let's say five, OK, and we are going to use the inside of this main function.

We are going to create to erase.

So end array one, OK, and we will need to be of size.

Let's put here some values.

So one, three, six, eight and 10.

And in the second array, what we are going to do is put some other values.

So for example, let's put it like two again, two, four, 11 and 17.

OK, so that's what we are going to do and to hold for the secondary.

So awesome.

We created our to erase in.

What we are going to do now is simply to swap between the values and how we are going to do that.

We are going to write down a function that first of all, is responsible for making just the swap between

two integers.

You do remember how this function looks like, don't you?

So these function is going those like this a wide swap, OK, and wide swap.

And there you go in star value one and end star value two.

And the function goes like this.

So in Tampa and Tampa equals to you value one end of value.

One now equals two value two and value two equals now two to what is equal to two temp.

OK, so if I'm not mistaken here or in any part mystically, guys, this is something we've done in

one of our previous videos is just the basic swap function between two values.

And the reason we are using pointers here, I'm not going to remind it, are right now because we don't

have time in this exercise.

But if you have questions, feel free to ask and I will try to redirect you to the exact video where

we talked about everything related to that.

So we have this web function and this function will not swap between all the elements of the array.

Right.

We need to call the swap function into for each pair of these values.

So what we can do is simply also create additional array and an additional function and call it void

swap o m OK o and ease the time complexity swap and swap arrays instead of like this.

Oh OK.

So simply it's, it's saying let me explain it to you guys.

So first of all let's receive both of the arrays.

So int IRR one end point or two and we know the size is this size the defined here.

So we can also use that or we could have got it as arguments for for, as parameters for this function.

OK, so the function is going to be like this.

So void printing are simply will receive the array so into Jutras and we know the size here is defined

so it doesn't really matter and, and I or I equals to zero as long as I use less than size I plus plus

we are going to print the values or print half percentage percentage the and we are going to print here

at I and also just to specify that we are done with this printing, just print in your line, print,

backslash and at the end.

Awesome.

So we have.

Three functions, you see how you improved.

I mean, there were times that we just were struggling to write one function, one basic function,

and we just use this machine.

And now we have created three functions, I think, in just a couple of minutes, and we are ready to

move on and to use all of them to solve our problems.

So what we are going to do is print F values before swap OK, or array values, array values before

the swap.

So what we are going to do now is to call the printer our function for an array one also do the same

for a year or two.

OK, you're with me and once we are done we are going to call the function swap array on and to use

it with array one and every two gay guys.

And what we are doing here is simply sending the address of the first element here.

And this is the address of the second element to here, making sure that simply all all of the function

is going to do is to just swap between the values.

So let's build and run it.

OK, so build and run and there you go.

Array values before swap are one three six eight, 10, four array number one and two to four.

You live in 17 for array two.

But after the swap has occurred, we will see that every one contains two two four, 11, 17 and the

array two has all the values that previously everyone had.

So that's freaking amazing, guys.

And once again, I want to explain what happened here.

Let's take another look.

OK, so we created, first of all, array one in every two.

Here they are behind the scenes and then we printed their values, OK, and there you go.

And then we call this Warlpiri in oh of A..

And give it a one in array two.

So we got here and simply iterated over all the elements of these arrays, one by one, taking each

time a value at a specific index.

So ARRL Index zero and here are two at index zero and making swap between both of them.

So that's what we got on the first iteration.

That's what we got on the second iteration after swapping these two values and so on.

So that's basically how we did it.

We sent here the address of a given value in this array of a given element and simply used there are

the common swap function.

And what was the time, complexity, the time complexity was o of and or of size of this array, because

we each created over all the elements of this ring.

And in one of the next videos I'm going to show you some deep and trig.

Sometimes interviewers like to ask this question on the interview questions.

It's going to be a little bit different question, but we are going to see how we can like I don't know

if it's called cheating or tweaking or whatever to swap to given a raise that after we kind of close

our eyes and open it up, we will see that both arrays have been changed and we can access them like

like this.

But all of this operation will be done in just two or three lines of code without using any for a loop

and without depending our answer on the size of the array.

So that's very interesting topic that will cover hopefully in the future.

So thank you guys for watching.

Keep on practicing.

Keep on moving forward.

And yeah, I, I think we are done for this video.

Bye bye.

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