Lab 1 is:
import java.util.ArrayList; import java.util.LinkedList; import java.util.List;
public class Day2_Lab1 { public static void main(String args[]) { List al = new ArrayList(), ll = new LinkedList();
myPopulateRandomly(al); myPopulateRandomly(ll); long start = System.currentTimeMillis(); int maxAl = findMax(al); long end = System.currentTimeMillis(); System.out.println("ArrayList findMax: max=" + maxAl + ", time=" + (end - start)); start = System.currentTimeMillis(); int maxLl = findMax(ll); end = System.currentTimeMillis(); System.out.println("LinkedList findMax: max=" + maxLl + ", time=" + (end - start));
} public static > T findMax(List inL) { if (inL.isEmpty()) return null; T max = inL.get(0); int listSize = inL.size(); for (int i = 1; i 0) max = temp; } return max; } public static final int MAX = 500000; public static void myPopulateRandomly(List inL) { for (int i = 0; i Requirements: Do the following: 1. Make sure you study Participation Activity 1.3.1 in the zyBook very carefully. You don't have to fully understand how Lists are implemented using LinkedLists and/or ArrayLists, but you should try to understand as much as possible 2. Ir the Lab1 class. implement the following method public static void myPopulateRandomly(List inList, int howMany) This mcthod populates inList with howMany randomly-generated ints. Note that inlist is either an ArrayList or a LinkedList. Regardless, your implementation must run as efficiently as possible. 3. Only use the List method add(int index, Integer element) in your implementation of myPopulateRandomly for adding elements to inlist. 1. In the Lab1 class, implement the following method: public static void myRemoveAll(List inlist) This method removes all the elements from inlist. Note that inlist is either an ArrayList or a LinkedList. Regardless, your implementation must run as efficiently as possible. 5. You CANNOT use the built-in List method removeAll in your implementation of myRemove All. 6. In your implementation of myRemoveAll, only use the List method remove(i) for removing clements from inList. 7. In the Lab1 class. implement the following method: public static int myHowManyGreaterThan(List inList, int target) This method returns the number of elements in inList that are strictly greater than target. Note that inList is either an ArrayList or a LinkedList is passed in? Requirements: Do the following: 1. Make sure you study Participation Activity 1.3.1 in the zyBook very carefully. You don't have to fully understand how Lists are implemented using LinkedLists and/or ArrayLists, but you should try to understand as much as possible 2. Ir the Lab1 class. implement the following method public static void myPopulateRandomly(List inList, int howMany) This mcthod populates inList with howMany randomly-generated ints. Note that inlist is either an ArrayList or a LinkedList. Regardless, your implementation must run as efficiently as possible. 3. Only use the List method add(int index, Integer element) in your implementation of myPopulateRandomly for adding elements to inlist. 1. In the Lab1 class, implement the following method: public static void myRemoveAll(List inlist) This method removes all the elements from inlist. Note that inlist is either an ArrayList or a LinkedList. Regardless, your implementation must run as efficiently as possible. 5. You CANNOT use the built-in List method removeAll in your implementation of myRemove All. 6. In your implementation of myRemoveAll, only use the List method remove(i) for removing clements from inList. 7. In the Lab1 class. implement the following method: public static int myHowManyGreaterThan(List inList, int target) This method returns the number of elements in inList that are strictly greater than target. Note that inList is either an ArrayList or a LinkedList is passed in