Exam2 Review

 

For the Exam

Topics to take special note of

LinkedList Iterator

Look at this code snippet. Where is the iterator after line one has executed? The | is the iterator

        LinkedList<String> list = new LinkedList<>();
        list.addLast("A");
        list.addLast("Q");
        list.addLast("X");
        list.addLast("Z");
        
        ListIterator<String> iterator = list.listIterator(); //line 1
        iterator.next(); //line 2
        iterator.add("K"); //line 3
        iterator.next();
        iterator.next(); //line 4
        iterator.remove(); //line 5
        iterator.next();
        iterator = list.listIterator(); 

Big O

When:

Big O

 

Sets

How would you go about finding the union of two sets?