Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions