Question: Need Assistance with the TODOS in code BELOW. Need them to be answered. package cs271.lab.list; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import org.junit.After; import org.junit.Before;

Need Assistance with the TODOS in code BELOW. Need them to be answered. package cs271.lab.list; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestPerformance {  // TODO run test and record running times for SIZE = 10, 100, 1000, 10000, ... // (choose in conjunction with REPS below up to an upper limit where the clock // running time is in the tens of seconds) // TODO (optional) refactor to DRY // which of the two lists performs better as the size increases? private final int SIZE = 10; // TODO choose this value in such a way that you can observe an actual effect // for increasing problem sizes private final int REPS = 1000000; private List arrayList; private List linkedList; @Before public void setUp() throws Exception { arrayList = new ArrayList(SIZE); linkedList = new LinkedList(); for (var i = 0; i < SIZE; i++) { arrayList.add(i); linkedList.add(i); } } @After public void tearDown() throws Exception { arrayList = null; linkedList = null; } @Test public void testLinkedListAddRemove() { for (var r = 0; r < REPS; r++) { linkedList.add(0, 77); linkedList.remove(0); } } @Test public void testArrayListAddRemove() { for (var r = 0; r < REPS; r++) { arrayList.add(0, 77); arrayList.remove(0); } } @Test public void testLinkedListAccess() { var sum = 0L; for (var r = 0; r < REPS; r++) { sum += linkedList.get(r % SIZE); } } @Test public void testArrayListAccess() { var sum = 0L; for (var r = 0; r < REPS; r++) { sum += arrayList.get(r % SIZE); } } } 

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!