Question: Input System.currentTimeMillis() to your code to get the run time of the following algorithms 1. public static int[] mystery2(int[] list) { for ( int i

Input System.currentTimeMillis() to your code to get the run time of the following algorithms

1.

public static int[] mystery2(int[] list) {

for (int i = 0; i

int j = list.length-1-i;

int temp = list[i];

list[i] = list[j];

list[j] = temp;

}

return list;

}

2.

public static int[] mystery4(int[] list) {

int[] result = new int[2*list.length];

for(int i = 0; i

result[2*i + 1] = list[i]/ 2;

}

return result;

}

3.

public static void mystery6(ArrayList list) {

for(int i = 0; i

list.add(i+1, first);

4.

public static void mystery8(ArrayList list) {

for(int i = 0; i

list.add(i%10,"Hello World");

list.set(i%20,"nothing");

list.remove(list.size()%30);

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!