From charlesreid1

No edit summary
Line 45: Line 45:
==Section 10.2: Comparable interface==
==Section 10.2: Comparable interface==


===Definitions===
===10.2 Definitions===


Definitions:
Definitions:
Line 51: Line 51:
* Natural ordering
* Natural ordering


===Materials===
===10.2 Materials===


First, need to mention unboxing: <code>ArrayList<Integer></code> vs <code>ArrayList<int></code>
First, need to mention unboxing: <code>ArrayList<Integer></code> vs <code>ArrayList<int></code>
Line 64: Line 64:
==Section 10.3: Vocabulary comparison==
==Section 10.3: Vocabulary comparison==


===Material===
===10.3 Material===


Some efficiency considerations
Some efficiency considerations
Line 78: Line 78:
* now, to deal with large files, print statistics (Nwords, Noverlapwords, Percent overlap)
* now, to deal with large files, print statistics (Nwords, Noverlapwords, Percent overlap)


=Chapter 10 Summary=
==Chapter 10 Summary==


==Deliverables==
===Deliverables===


ArrayList
ArrayList
Line 97: Line 97:
* Compute statistics
* Compute statistics


=Chapter 10 Goodies=
==Chapter 10 Homework==
 
===HW Questions===
 
(Recommended) Self-check problems:
 
(Required) Exercises:
 
(Required) Projects:
 
===HW Details===
 
Self-check:
 
Exercises:
 
Projects:
 
==Chapter 10 Code==
 
===Lecture Code===
 
NEED TO DO ALL OF THIS
 
===Worksheet Code===
 
NEED TO DO ALL OF THIS
 
==Chapter 10 Goodies==


==Profiles==
==Profiles==

Revision as of 02:13, 14 September 2016

Chapter 10: ArrayLists

Sections:

10.1 ArrayLists

10.2 Comparable interface

10.3 Case study: Vocabulary comparison

Section 10.1: ArrayLists

10.1 Definitions

Definitions:

  • Generic class
  • Wrapper class
  • Boxing
  • Unboxing

10.1 Materials

Introduce ArrayList object the way you would introduce the Python list

  • List: basic data type, very important
  • Difference between list and array - memory allocation and element insertion
  • Dynamic arrays

Array notation

  • Wrapper class, everything is an object, treat primitive types as objects

What kind of things would you want to do with an ArrayList?

Basic basic operations:

  • Get size

Other basic operations:

  • Get item at index i
  • Set item at index i
  • Add item, add item at index i
  • Remove item
  • Modify item at index i

Now that we have defined these basic operations, we can move on to examples/algorithms/implementations.

Section 10.2: Comparable interface

10.2 Definitions

Definitions:

  • Comparison function
  • Natural ordering

10.2 Materials

First, need to mention unboxing: ArrayList<Integer> vs ArrayList<int>

  • Unboxing is a really stupid side effect of Java's implementation
  • Everything is an object. Except the primitive types. But everything is an object.

Comparison of objects

  • extend idea behind o1.equals(o2) to comparisons
  • lt/lte/gt/gte
  • how to redefine comparison operator for our own objects

Section 10.3: Vocabulary comparison

10.3 Material

Some efficiency considerations

Version 1: compute vocabulary

  • Add unique words to ArrayList, and sort

Version 2: compute overlap

  • Number of matches between two sentences

Version 3: complete program

  • so far, build vocab list for 2 files, compute overlap between them
  • now, to deal with large files, print statistics (Nwords, Noverlapwords, Percent overlap)

Chapter 10 Summary

Deliverables

ArrayList

  • Notation, how to use it
  • Conceptualizing problems that can be easily resolved with ArrayList
  • Adding/removing and looping over ArrayLists
  • Wrapper classes

Comparable

  • Natural ordering and compareTo() function
  • Implementing the Comparable interface

Case study: Vocab comparison

  • Count number of unique words
  • Count overlap between two lists
  • Compute statistics

Chapter 10 Homework

HW Questions

(Recommended) Self-check problems:

(Required) Exercises:

(Required) Projects:

HW Details

Self-check:

Exercises:

Projects:

Chapter 10 Code

Lecture Code

NEED TO DO ALL OF THIS

Worksheet Code

NEED TO DO ALL OF THIS

Chapter 10 Goodies

Profiles

More Caesar ciphers, once they finish with this worksheet they'll be ready for the affine cipher

Puzzle 2

Flags