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
OK, so now let's try to solve it together, shall we?
First of all, let's also create maybe additional, I don't know.
Let's just use some define size for.
And let's create our array.
So let's use an array of integers, doesn't really matter.
OK?
Because we are simply doing it like they're so innocent.
Let's go with array of values of values, error of size, and it will be initialized through the following
values of five, four, seven and three.
OK.
That's it.
So you could read these values from the user.
You could do whatever you like, but for now, we already know how to read values from the user, how
to work with them.
So now what interests us is how we can simply make this algorithm of rotating to the left a given array
by one position.
So what is the main logic behind it?
What should be done?
What do you think?
What should be done?
OK.
So how can we take all of these elements and rotate them to the left?
If we would say, for example, like Valley, you say you are OK, values IRR at index, let's go size
minus one.
Equals.
To values a rather.
Values air at index zero, then that can be a problem, because after this operation, this value of
five would come here, right?
And the value of three will no longer exist.
OK, so that's a problem.
That's one problem.
The next problem is how you rotate all the other elements to the left.
Well, that's actually not the.
The most difficult thing in this exercise, because that's going to be probably a very simple loop that
will start from equal to one until I is less than size, right?
And then on every iteration you will simply use like values they are at index I equals two values.
Zero rate index minus one equals two values that are at Index II.
OK, so that's one of the options.
So that's about the for a loop of these parts.
But what about the others?
So what is important in this exercise is to understand that the precedence in this case who will be
done before the other is very important.
So what will we will do is the following we will see that we will create additional variable.
OK, we'll create like end temp, OK, temporary variable, and we will store inside of these temp variable.
We will store what we will store the value of error at index zero.
So we will say that values.
IRR at index zero, that would be the first step.
OK, so we have these temp with a value of five.
Then what we will do is we will rotate left.
I will show you in the code in a minute.
Rotate left.
All elements, all elements, OK, all elements from AI equal to one up to AI less than size.
So I'm just writing down the algorithm the main steps that we are going to do.
So after this operation, what we will get in the array?
OK, I just want to show you after this operation.
OK, rotate left all the elements from equal to one two, i.e. less than size.
We will have four, seven, three and three.
OK, this will be a duplicate that you will see.
And after this one will be over.
We will be able to say that values a RA at the last index, which is size minus one, will be equal
to what?
Did a value inside variable Tim, so we did not lose anything, neither from the left side nor from
their white one.
OK, so that's the whole explanation about it.
And that's the main steps that need to be taken care of.
Now with that being said, I hope it's clear so far what we will do is we will write the actual code
for it.
So let's create additional variable that will assist us in the process of looping.
So I, in what we will do, will create a variable and will also use the term variable for storing these
values so that the left most element or the right most element will not be overwritten.
So now what we will do is we will say temp equals two values, they are wrong at one index at index
zero.
Awesome.
Then what we will do is we will do a for loop and for a loop that starts from IE equal to one.
As long as I is less than size right, so far, so good.
I + +.
And we will say that values there come on at Index II minus one will be equal to value, 0r at Index
I.
OK.
Is it enough?
So what we do is we basically, first of all, took these value of five.
Put it aside, then we simply said, OK, so let's start and copy.
OK, I'm just going to map it to you right now.
So that's basically what we do.
We take these value offshore and put it inside here.
OK, so we say at index zero, put the value from index one.
So here we go four.
Then we take the same four, seven three and basically we are done right.
Because that's the last element.
Four ice equals to size minus one.
So that's the last element.
And we put it in the previous one.
So make sure that you start from equal to one because there is also an option to start with equal to
zero.
But then you will need to make sure that you do not go up until I's list in size, but rather ice less
than size minus one.
Otherwise, in this approach, you will probably make sure you did not.
But if you did this way, you are probably exceeding the size of the array.
OK.
The boundaries are awesome, so that's what we have at this moment.
And finally, all that remains once we are out of this for a loop is to say, OK, instead of this value,
we will use the value of faith in the value of five was stored inside the 10 variable and what index.
These value has this value, this element is with index size minus one.
So that's why we are going to do the following we will say values there are.
At index size minus one will be equal to temp.
OK, of course, all of that, not under the for a loop that's going to be right afterwards.
All right.
Is it clear, guys?
I really hope it is.
And basically after this operation, we have mustered and completed a story about that a program that
should rotate left a given a three by one position.
So you can try to print it out, okay, you can add the printing functionality, you can print this
array to make sure that it works, bring the array, whatever you like.
OK, it doesn't really matter because in this exercise, we basically try to focus and to make the best
in order to implement the logic, the algorithmic approach behind it.
Printing, you already know by now how to do so.
You can test it out.
Always just end the associated lines of code.
OK, so later on when you proceed and when you become better and better are developers.
You will see how you can take all of these functionality and put it inside a totally separate function
that will be called like, I don't know, rotates left by one position.
And this function will be capable of receiving an array and basically just making one rotation to the
left.
OK, but for now, that's the main important part.
We have created this program.
We are ready to move on.
So this exercise is the basis for a couple of additional exercises that I will show you in about a couple
of minutes, hopefully.
So thank you guys for watching.
Keep on practicing.
Keep on moving forward and you are bound to succeed.
I'll see you next time.
Bye.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.