2016-03-18 Linked List testing

posted Mar 18, 2016, 7:04 AM by Samuel Konstantinovich   [ updated Mar 18, 2016, 7:04 AM ]
Goal: Compare your LinkedList to ArrayList

Do Now: 
Log in, open site, while discussing:
Which operations of myLinkedList should be faster/slower why?
Can we improve them?
How can we test this?

For the weekend:
Complete your linked list, include optimizations to add to the end of the list. 

Better than using the time command, we can test milliseconds in java using the System.currentTimeMillis() command.
This returns a long not an int, so be careful.

import java.util.*;
public class Driver{
    public static void main(String[]args){
MyLinkedList m = new MyLinkedList();
ArrayList<Integer> n = new ArrayList<Integer>();

long start,end;

start = System.currentTimeMillis();
        //code to test here on ArrayList n
end = System.currentTimeMillis();
System.out.println("Time: " + (end-start)/1000.0 + " seconds for ArrayList");

start = System.currentTimeMillis();
        //same code to test here on linked list m
end = System.currentTimeMillis();
System.out.println("Time: " + (end-start)/1000.0 + " seconds for MyLinkedList");

    }
}

Comments