Question: ` ` ` java public class JavaApplication 1 5 5 { static void forYou ( ArrayList x ) { int n = x . size

```java
public class JavaApplication155{
static void forYou(ArrayList x){
int n = x.size();
int[] array = new int[n +1];
int y =1;
for (int a : x){
array[y]+= a;
}
for (int it = n /2; it >0; it /=2){
for (int i = it +1; i < n; i +=1){
int temp = array[i];
int j;
for (j = i; j > it && array[j - it]> temp; j -= it){
array[j]= array[j - it];
}
array[j]= temp;
}
}
for (int i =1; i < n; i++){
x.remove(i);
x.add(array[i]);
}
}
public static void main(String args[]){
ArrayList list = new ArrayList<>();
list.add(16);
list.add(12);
list.add(11);
list.add(10);
list.add(16);
forYou(list);
System.out.println(list);
}
}
```

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!