8.5 tables Challenge correction

Hello, welcome to this new course, we will perform the correction of our last challenge which consists in ... creating an array Then sorting the elements of the array So to start we have our getTableau Method which we ... returns an array of integer and takes as parameter the capacity of the array then to line 20, I have you uliser ... a scanner that will allow us to enter them from the Clique At line 22, I have created a table that ... will contain the elements. That the user will enter The size of our Va table corresponds. To the value the user will enter ... enter. Then I ask the user the values. I use the for loop to browse the So int i array equal ... to 0 as long as i Is less than the size of the array. I increment i Then I get the value that ... the user will enter. Then I do tab[i] Equal to the value. So in our loop every turn I will ... change. It’s going to start part 0 1 2 3 Up to the maximum capacity And i matches index 0. we’ll get the value. That the user will enter Then leaving the table I return Our table that will contain ... all the elements That the user has entered Then I have the method printTableau Who will allow us to display the elements of our ... table. it takes as parameter an array of Integer then I use the loop for To browse our array and display ... the index i the element that corresponds to the displayed index So if There is the index 1 It will have the element 1 that ... will be displayed. Or value Then I created the trieTableau method which is a little more costeau. But also, the ... method permute. I will first explain to you what this will consist of, this method permute. It takes as parameter one ... array And two integer values And I make a condition if a == b I return nothing. Then, here, I ... will swap the values. I will recover. The first element of our table that will be equal var1 And the ... first element of the table will be equal. At the second element and the second element will be equal to the ... first element. Explain in this way, it’s a bit hard to understand, but in this explanation you go very well ... understand how this permutation works. This function swaps. So to start our method trieTableau Will return us an array. And ... it takes as parameter. An integer table In line 43 I created a table. Which will contain all the ... elements of the table Setting The line of our table will match the size of the table that have friends in ... setting. and line 47 I used the for loop to go through our table That we put in parameter And ... I get the elements of our table `I put it in the new table. Now to sort the table, ... I will start From right to left So I did the opposite direction of course, we can do it from ... left to right too. I’m going to zoom in. I used the loop for I have a condition. So I get the last ... index of our table. It means that if our table is 0 TO 5 I will start part 5 ... 4 3 2 1 0 Then here I say. The last index Is greater than 0, I decrement. The last ... Index If it has 5 In each round, it will be decrementing 5 4 3 2 1 0 Our second forum ... will allow to sort the values. From the largest to the smallest To start int From i equals ... 0 and i Less To the last index As long as i is lower in increment i Then in the forum I ... make a condition if The first element of the table is lower than the second element the two values are swapped. In our Permute method. It is called. Method sorts array It will allow to swap. The elements of the new array ... So it takes as parameter. The New Table Then The First Value and The Second Value As I explained everything ... there the heur In this method, I switch. The first element and the second element therefore call this method If ... the first value the first element And greater than the second element The permutation will not be done. But ... we go through The table It will go through each element. and check if the following element greater than It will ... swap. So if element two is greater than element three. The condition will not be made, but if element ... two. Is smaller than element three. we will swap element three to second place, I hope you understood this Condition At the beginning it’s a bit complicated But try to write well on a sheet to understand well ... Then I used the for loop to display the elements of course, so we don’t need to delete. Steps given that we have a method. which naked displays all the elements. Now we will test our program, but before ... all our in hand method. I used an object. Scanner Who will allow us to read, enter it from keyboard. So ... the user will enter the capacity of the table, which is the size of the table. Then I created a table. Which will be equal ... . To our method getTableau that returns us an array Then I call our method trieTableau That will also match to ... a given States array that returns us an array also And in this method call I pass first. The size of the table in getTableau Then in our table sorts Table I pass the table as the user. Will enter. and in our method print table I will display everything. Value So all elements We have Sort to ... from the method. sort Table Compiling our program So enter the ability of the table we put 5 Enter values ... Now we have. Bigger to smaller And if you had passed all his exercises To be able to sort the ... values from smaller to larger order All you had to do was change Our condition ... here We will remove. Inferiors, we’re going to be superior. We’re going to recompile our program. Enter the capacity of the table We ... will put 5 Values And there We value its display from the smallest to the largest I hope you ... understood. the whole of this challenge tried to do it again Several times To understand this concept well Thank you for having ... follow this challenge soon.