Tuesday, May 9
Final exam: Tuesday, May 16, 6:30-9:30, M-2-423
Bring books, pa’s, hw’s, labs, posted solutions
The final will cover the textbook material for the whole
term, all hws and labs, and pa4, pa5, and pa6. So study the posted solutions
for pa4, pa5, and pa6, and bring copies to the final.
Textbook Coverage
Chap 1-3—background
Chap 4:
- Still skipping classification of exceptions, Fig. 4.17.
You should understand the exceptions we used in pa’s. Similarly you don’t
need to be an expert on Java file classes, discussed in pp. 114-118.
Again, be guided by what’s in the pa’s.
- Nested classes are intro’d here. We are now covering
private nested and inner classes, but we’re still skipping local and
anonymous classes (4.7.2 and 4.7.3)
- Also you can skip 4.9, dynamic binding.
Chap 5—Big Oh only, but important! sequential vs. binary
search also important, but skip interpolation search.
Chap 6—Collections, the most important JDK classes we
studied.
- pg. 211 the Collection interface, very important. Can
skip pp. 216-217 Collections class, surprisingly not so important.
- JDK sorting—important, as is binarySearch.
- List interface/ADT, ListIterator, LinkedList all
important.
- Stacks: recall they have 2 APIs, Weiss’s (with topAndPop)
on pg. 226, JDK(with pop of element)—see pg. 558. Best to implement
either one with LinkedList.
- Queue, also 2 APIs JDK, pg. 229 (with “element” call),
classic-names API (enqueue/dequeue) pg. 546, 554.
- Which (if any) of these stack/queue classes provide
encapsulation so that you can’t see their interior elements?
- Sets: Set API = Collection API, HashSet and TreeSet
concrete classes in JDK. These are easy to use for elements of type
Integer, String, Character, etc., since these language-supported object
types have equals, compareTo, and hashCode all implemented perfectly for
us. Don’t worry about the harder case of user-defined objects for
elements, for the final.
- Map<X,Y>, not Collection, but important, HashMap, TreeMap—most
powerful JDK container classes. Easy for key types Integer, String,
Double, etc, and will stick to these for the final. The value type can be
a user object type without difficulty, recall Map<String, WordStats>
for example.
- Priority Queues: wait to CS310 for these, so don’t worry
about them now.
Chap. 7 Recursion
- No sigma notation on final
- Basic recursion 7.3—important. You gotta believe idea:
trust your recursive call.
- Tree of calls, idea of bad recursions
- Definition of tree, binarySearch by recursion. Note
similarity to mergeSort calling pattern.
- Skip rest of chapter
Chap. 11 –study was related to pa3, so don’t worry about it
for final
Chap 15—Inner Classes and ArrayList
- More on iterator implementation, after intro in Chap. 6.
You can skip all the buildup and go straight to the standard solution on
pg. 522, where an inner class is set up that implements Iterator, and the
object created can be passed back to the caller as an Iterator object.
- pg. 523—don’t worry about the special problems of public
inner classes—we only need private ones.
Chap. 16—Stacks and Queues, their implementation by arrays,
linked lists
- You should know that push, pop are O(1) for both array and
linked list implementations, at least if we can ignore the need for array
expansion occasionally with the array case.
- Similarly, enqueue and dequeue for Queue are also O(1) for
both arrays and linked lists. To get this with an array, we need to use
the trick of wrapping the elements around from the end back to the
beginning of the array.
- We looked at the ArrayListIterator and did a similar thing
in pa06
Chap 17 LinkedLists
- idea of header nodes and all the connector nodes needed to
build this data structure
- how the iterator works
Chap 18—Trees: binary and general trees, as we used for XML
- XML—know about elements, text nodes, and how to use the
Node interface of DOM
- Trees: Should know paper-and-pencil traversals: preorder, inorder,
postorder, as well as insert, etc.
- Can skip 18.4, tree traversal iterators: just understand
the recursive traversals such as PrintPreOrder, and the other recursive
tree functions of 18.3.
- Normally the height of binary tree of N nodes is O(log N),
unless it’s badly unbalanced. So we say that normally insert, delete and
lookup in a binary tree are all O(log N).
Chap 19—BSTs
- BST property, pg. 630
- Insert, find, remove—should be able to do on paper, in
code
- 19.2 order stats, i.e. “rank”—used in pa06, should be able
to make pictures for this too
Chap 8 Sorting
- insertion sort O(N^2) mergeSort, a better sort, O(N logN).
Note that JDK sort is a quick sort, not covered.
pas covered on final
Note that you can improve a low score on one pa by doing OK
on the final’s problem on that pa.
pa04 --recursion
Expand: recursive file inclusion
Combo: #combinations by recursion
ComboSet: can ignore
pa05—Trees and XML, just elements, attributes and text nodes
don’t worry about attributes for the final
pa06—OrderedList API with BSTWRank implementation
Think of model for OrderedList: sequence of elements in
order, with numeric positions as well. you can insert a new value and it goes
into the right spot in the ordering. You can look up elements by key or
position.
Example of implementation of non-JDK Collection class, using
help from AbstractCollection, i.e., JDK infrastructure
Example of adapter class: a BSTOrderedList HAS-A BSTWRank,
implements add by calling insert, etc.