Question: Write a java program that calls a method called reverse4 that accepts an ArrayList of integer values as a parameter and sorts each successive sequence

Write a java program that calls a method called reverse4 that accepts an ArrayList of integer values as a parameter and sorts each successive sequence of four values in the list in the descending order. If the list has extra values that are not part of a sequence of four, those values are unchanged. For example if a list stores values [10, 13, 2, 8, 7, 90, -1, 2, 4, 5], after the call the list should store the values [13, 10, 8, 2, 90, 7, 2, 1, 4, 5]. The first sequence of four (10, 13, 2, 8) has been rearranged to (13, 10, 8, 2). The second sequence (7, 90, -1, 2) has been rearranged to (90, 7, 2, 1) and so on. Notice that 4 and 5 are unchanged because they were not part of a sequence of four values. Print the array before the call and after the call.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!