|
Comp202: Principles of Object-Oriented Programming II
Fall 2007 -- Exam
2
Need-to-Knows
|
This list should be considered
a partial list at best! Check back often to see if new items
are added. You are responsible for all topics covered in class, labs
and assignments, even if they do not appear here.
- Command-passing architectures, ala Rice MBS and
self-balancing B-trees.
- Virtual-host architectures for visitors, ala Rice MBS.
- Extended visitor pattern to handle arbitrary numbers
of hosts, ala self-balancing B-trees.
- Algorithms on B-trees (TreeN).
- Be able to write visitors to a TreeN.
- Be sure you understand how the insertion and deletion
algorithms work.
- Dictionaries
- What is a dictionary?
- What are key-value pairs for?
- Hashing and hash-tables
- Understand the notion of hashing,
- What it is for?
- Advantages over binary search tree?
- Relationship between a hash table
and a dictionary?
- Hashing functions:
- What constitutes a "good" hashing function?
- Rehashing
- Chaining
- Using a hash table, in particular, Java's HashMap
class. Practice writing code to
- Store key-value pairs in a HashMap
- Retrieve values from a HashMap using a key
- Detect if a key doesn't exist in the HashMap
- Parsing
- Tokenizing
- Factoring
- Expressing of grammar in terms of classes.
- Review on anonymous inner classes:
- Initializer blocks
If you need to do constructor-like processing in an
anonymous inner class, use initializer blocks, which are execute only once, when the object is instantiated:
IClass c = new IClass() {
// initializer block defined by a pair of curly braces
{
// Runs after the superclass constructor.
// Call methods here.
// Set fields here.
// All needed variables are in scope!
// etc.
}
// regular method and field definitions
};
- Referencing nested anonymous inner classes:
An inner class can reference the outermost class and itself, but not any
classes in-between. To get around this, simply create a field in
the inner class one wishes to reference that hold a reference to that
object:
IClass c = new IClass() {
IClass first_c = this; // save the reference to the outer object.
IClass another = new IClass() {
// "first_c" is in scope, so this object can reference it.
};
};
Last Revised
Monday, 25-Jan-2010 16:14:00 CST
©2007 Stephen Wong and Dung Nguyen