Lecture 11:
Review for Exam
Announcements
H4: was due at
look at the posted solution
exam: Thursday,
one page of notes
bring a pencil
P2: due tonight at
demo contained errors – have been corrected; let me know
inserting a duplicate task didn't throw an exception
error message for bad file didn't name the file
list can contain null
§
your
contains(ob) method should handle that case
§
don't
have to worry about that on the exam
if you add a duplicate task, it should throw an exception
Exam topics:
Lists
·
the
List ADT
·
ArrayList and LinkedList
implementations
·
manipulations
of linked data structures
·
downcasting when retrieving items of a specific type
·
iterators
Complexity, big-O notation
worst case running
times for
·
ArrayList methods
·
LinkedList methods (singly-linked list, lastNode field)
·
doubly
linked lists
·
code
we give you
Exceptions
·
how
to throw, how to catch
throw new ex-type(); //note "new" and
"()"
try{ … }
catch(IOException ex) {…}
·
how
to define a new exception
public class myException extends RuntimeException {
} // often leave the
exception class empty
·
checked
vs unchecked
Stacks & queues
·
complexity
of operations
·
how
to write code to use them
·
not: how to implement Queue using an array or ArrayList
iterators
import java.util.* //
defines the Iterator type
public Iterator iterator()
{ // in the ArrayList class
return new ListIterator(this);}
class ListIterator implements Iterator{
… // define fields here
public
Boolean hasNext(){…}
public
Object next() {…}
public
void remove() {…}
}
Iterator it = L.iterator();
while (it.hasNext())
{
ob = it.next();
…
}
or
for (Iterator
it = L.iterator(); it.hasNext();
) {
Object ob = it.next();
…
}
Previous exams
Fall
03
o
ignore
Part II Q3: array implementation of
Queue
o
ignore
circular list in Part II Q1
o
part
I Q6: not well-worded
Fall
'99
o
ignore
Part I Q9 & Q10: circular array
implementations
Thursday's
exam
·
similar
range of questions
·
similar
difficulty
·
some
questions are subtle, read all possible answers
·
don't
rush through
Lecture
12: exam #1