announcements‎ > ‎


posted Mar 23, 2016, 7:14 AM by Samuel Konstantinovich   [ updated Mar 23, 2016, 8:41 AM ]
Do Now:

You write a main that is not inside of the linked list class and make two lists, and then populate them:
LinkedList k = ...
ArrayList a = ....

Given two functions you want to write, that calculate the sum of all of the elements in each (assuming numerical lists): 
static double sumL( LinkedList)
static double sumA( ArrayList)

First:(2 minutes on your own outline this)
How would you write the sum functions? 
What would their respective complexities be? 

(3 minutes discuss and compare algorithms)

What are you not able to do efficiently?
What feature/ability do you wish you had access to in a Linked List that we do not currently have? (do not negate the previous answer)


Iterable vs Iterator:
Iterator example: scanner (something meant to go through once), 
Iterable examples: lists, sets, etc. (other things you may loop through twice)

A class that is a collection (list, set, etc) should implement Iterable, and the iterator it returns would access the inner state of the collection. 

Code Demo...