CS210 Thurs., Mar. 23

Went over practice exam--soon see solutions linked to class web page

Review

Text coverage:
Chap 1-2 review
Chap 3 review, but did 2 problems in hw1

Chap 4 inheritance--crucial semi-review, be sure to re-read!
       what a subclass can do--add methods and fields, but not remove any

       Type compatibility and IS-A, including array types

       abstract classes: used in pa1, and in implementation of JDK collections
       interfaces--crucial
       exceptions--ex in pa1. Won't ask about Fig. 4.17 (haven't really covered this.)
       File classes--not on exam, need for pa's.  Too much of a mess.

       Generics

       the primitive wrapper types Integer, etc., autoboxing/unboxing for them

       adapters--like PureStack

       Note that figure 4.27 is old Java, ignore such

       interfaces for genericity--important, used in pa1, Collection classes

       wildcards with bounds, generic static methods--understand examples, I won't ask for new code on this

       type erasure--know what this means, hw2 problem

       functors--need for Comparators in sort, binarySearch.  Comparator our only real example so far
       nested classes--only know how to pull them out so far, skip rest of chapter.
       key concepts--pg. 150 useful summary

Chap 5 Algorithm Analysis

       Big Oh only, emphasis on N, N^2, N^3, etc, polynomials, log N,
       and combos with N^p.  Also p^N, exponential.
       Can skip 5.3
       5.4--Big-oh definition, simplifying
       5.5--log, important properties
       5.6--sequential (O(N)) vs. binarySearch (O(log N)), much faster
       interpolation search--can skip
       read rest of chapter, but less important

Chap 6 Collection Classes
       iterator--emphasis on *use*, not implementation, so far
       i.e., iterators as supplied by JDK classes
       idea of "factory method" (pg. 207)
       Collection interface, pg.211: this is our official subset
         for cs210.  In cs310, we'll look at some more methods here.
       Don't worry about UnsupportedOperationException.

            Instead, assume any Collection we're studying gives good implementations for all these methods.
       Iterator interface. Parametrized by element type.

       Comparator<T> again.

       Fig 6.13-6.14, can skip, tho note useful max method.

       Sort (O(NlogN)) and binarySearch (O(logN)) via Collections API--we did examples, and hw problems
       List Interface--important, have concrete classes ArrayList and LinkedList
       ListIterator--2-way iterator
       LinkedList class: 
         have picture that explains performance:  Here is the (usual)
             case that the elements are all different objects.

                    ------------------------------->
                   <--------------------------------
             LLobj --> connector --> connector --> connector
                  <--     |      <--    |      <--   |

                          |             |            |
                    element       element       element
      
      
          This explains why next and prev are O(1) for a ListIterator, etc., and can remove first or last element quickly

         Note Fig. 6.19 is simple list, not LinkedList


              Stacks: 3 versions:  Stack "protocol" by Fig. 6.21 (hides non-top elements)
                                           JDK Stack, with iterator(), etc.
                                           JDK Stack "PureStack" adapter (hides non-top elements)
                         Stack apps: CheckParentheses.java, pa3

              Queues: classic "enqueue, dequeue, getFront", also "isEmpty" (hides non-front elements)
                         Queue app: logging for a program, see notes for last time

                        JDK Queue: add(), element(), remove(), plus iterator(), etc.

              Sets: 1 version, Collection API
                         Set apps: Fig. 6.26, 6.27, stopwords set of pa2.  Also Fig. 6.30, but let's stick to TreeSets for anything other than 

                              wrapped primiitive type keys, i.e., take this as a warning not to use hashing in advanced ways before cs310.

                          Two concrete implementations in JDK: HashSet, TreeSet

              SortedSet interface, implemented by TreeSet
              TreeSet--JDK class, maintains order, lookup O(log N)
              HashSet--JDK class, no order, lookup O(1) by hashing (studied in cs310)

              equals and inheritance--on hw2, tricky!  IS-A isn't a strong enough test here, need class equality test in base class
              Maps--very important, core of pa2

              JDK has two concrete classes, TreeMap and HashMap, with O(log N) and O(1) lookup performance for keys.

              Map app: Fig. 6.33, studied in hw2.

              PriorityQueue--can skip

Chap 11   for pa3, also hw3.  Study hw3 solution--there may be easier ways to do the problems than you thought.

PA01

Interfaces, abstract classes, coding an inheritance hierarchy, adding your own exception

Using a tester class that takes advantage of the interface to avoid repetitive code.

Using ArrayList.

PA02

Tokenization as a means for subdividing work and defining the job being done, using Scanner

Setting up classes to do various parts of a job.

Using a Set for filtering out unwanted data.

Using Maps to hold facts needed for an analysis.  Even Maps with Maps in their value objects.

Specifically using TreeMap for its ability to keep keys in their natural order.

Using the Random class.

Designing a customized analysis object with a simple interface for the app.

Using main of a class for unit test code.

Having an application class that doesn't do much detail work, mainly calls on its classes and makes them do the work.

PA03

Tokenization again, again making clear what is important in the input.

Unnesting nested classes, to show that in this case it hardly matters whether they are nested or not.

Idea of scoring for decision-making, in a case where ties are broken by a secondary consideration.

Use of stacks to do calculation.

Idea of a pure stack, with severely limiited operations, but does the job here.

Idea of using an adapter class to implement a pure stack from the operation-rich LinkedList (or ArrayList.)

Technique of providing toString for elements and collection classes, and seeing the useful result.

Refactoring: incremental improvements to code.  Here several examples, but most obvious is sealing up Precedence.

Lab 1

Intro to Dr. Java, compiler errors vs. runtime errors.

Lab 2

Debugging

Program Crash--interpret backtrace, find offending line of code

Program runs, but produces bad results.  Determine first bad result.  Figure out breakpoints that will get you to this point.

Single-step code across suspect actions.  Understand and use step into, step over, step out.

Lab 3

Using the JDK Javadocs.

How to find documentation on methods for this class and ones that "come along for the ride" because they are available in a superclass.

How to find all the superclasses and superinterfaces.

hw1

Review, accessibility of fields,

Adapter vs. wrapper, type erasure, downcasts, array type compatibility

Basic Big-oh.

hw2

Big-Oh analysis of code, TreeSet app, HastSet app

Doing equals correctly for Base/Derived objects. 

Map app, using Scanner.

hw3

Stack app for balanced parentheses, calculator. 

Models for List, Stack, Set--add Queue here now--what you can do, how to do it.

How to call JDK sort and binarySearch.