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, 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.