public static LinkedList<Integer> doLinkedListSearchSmallest(int numItems) { Sys
ID: 3923572 • Letter: P
Question
public static LinkedList<Integer> doLinkedListSearchSmallest(int numItems) {
System.out.print("doLinkedListSearchSmallest: ");
LinkedList<Integer> list = new LinkedList<>();
for(int i=0; i<numItems-1; i++){
list.add(0);}
long startTime = getTimestamp();
// TODO Write code that gets the element at the first index from list.
long endTime = getTimestamp();
long totalTime = endTime - startTime;
System.out.println(totalTime);
return list;
}
Explanation / Answer
Here i am just providing the TODO part as only thats expected.
We can get element at first index as below:
List stores element as object so
list.getFirst(); // function predefined
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.