35.9k views
1 vote
In java !

For each of the following tasks, draw what the initial array looks like, diagram how you would solve the problem, and draw what the final array looks like. Then use your diagram to write a step by step process to solve the task. The diagram may show several separate steps, or you may want to use arrows to show how the data will be moved. It will be helpful to number the arrows in the order you draw them.


Given an unsorted array of integers create a sorted array by finding the
largest element in the array and swap it with the last position. Then find the largest
element in the array, ignoring the last position, and swap it with the second to last
position. Repeat until you are only considering the first position (element at index 0).
The initial array is : int array[] = {22, 15, 33, 4, 12, 2, 3, 19 };

User Jannette
by
3.7k points

1 Answer

2 votes

Answer: The attached photo is the code I use to sort the array from Greatest to least. If this doesnt help, I'm sorry.

Step-by-step explanation:

In java ! For each of the following tasks, draw what the initial array looks like-example-1
User Aleksei Zabrodskii
by
4.4k points