Java Collections Framework
Intro to Trees
Checkout BinaryTrees from SVN
Pascal partner evaluation in Moodle due Weds
night
Hopefully you are close to finishing either
Hardy or Evaluator by now and gotten a start
on the other one.
◦ If not, it is time to get moving!
Rose is teeming with teams
No prima donnas
◦ Work together or divide work equitably
◦ Working way ahead, finishing on your own, or
changing the team’s work without discussion:
is selfish
harms the education of your teammates
may result in a failing grade for you on the project
No laggards
◦ Coasting by on your team’s work:
is selfish
harms your education
may result in a failing grade for you on the project
I’ll assign an overall grade to the project
Grades of individuals will be adjusted up or
down based on team members’ assessments
At the end of the project each of you will:
◦ Rate each member of the team, including yourself
◦ Write a short Performance Evaluation of each team
member
Excellent—Consistently went above and beyond: tutored teammates,
carried more than his/her fair share of the load
Very good—Consistently did what he/she was supposed to do, very
well prepared and cooperative
Satisfactory—Usually did what he/she was supposed to do, acceptably
prepared and cooperative
Ordinary—Often did what he/she was supposed to do, minimally
prepared and cooperative
Marginal—Sometimes failed to show up or complete tasks, rarely
prepared
Deficient—Often failed to show up or complete tasks, rarely prepared
Unsatisfactory—Consistently failed to show up or complete tasks,
unprepared
Superficial—Practically no participation
No show—No participation at all
Ratings must be supported with evidence
Performance evaluations document:
◦ Positives
◦ Key negatives
Performance evaluations are standard
procedure in industry
◦ Why might that be the case?
Document dates and actions:
◦ Jan. 1, stayed after mtg. to help Bob with hashing
◦ Jan. 19, failed to complete UML diagram as agreed
List positives:
◦ The only way to help people improve!
List key negatives:
◦ Not all negatives
◦ Egos are too fragile for long lists, can’t fix
everything at once anyway
Keep a journal about the project
I’ll grade your evaluations
Your evaluations may be shared with the team
member being evaluated.
Don’t keep your feelings to yourself
Get me involved if your team can’t work out an
issue!
Review: Java Collections Framework and
Iterators
Introduction to trees
Begin binary tree implementation
Today or tomorrow will include some work
time
Q1
Available, efficient, bug-free
implementations of many key data
structures
Most classes are in [Link]
Weiss Chapter 6 has more
details about collections
Q2
Done with an interface, e.g., [Link]
A “factory
method”
Q3
In Java, specified by [Link]<E>
ListIterator<E> adds:
ag can be any Collection of Integers
The Java compiler translates the above into this:
addAll(Collection other)
containsAll(Collection other)
removeAll(Collection other)
retainAll(Collection other)
toArray()
Handy [Link] utility methods:
See
Collections
for similar
methods on
Lists
Q4
[Link]
◦ Shows "bare bones" possible implementations of
some of the classes in [Link]
◦ Illustrates (just) the essence of what is involved in
implementation
[Link]
◦ Some other data structures, not found in
[Link]
◦ Some alternate approaches to some classes that are
also in [Link]
See links from day 8 and 9 of schedule
Introduction and terminology
Class hierarchy tree (single inheritance only)
Directory tree in a file system
Q5-7
A collection of nodes
Nodes are connected by directed edges.
◦ One special root node has no incoming edges
◦ All other nodes have exactly one incoming edge
One way that Computer Scientists
are odd is that our trees
usually have their root at
the top!
Q8
Parent
Child
Grandparent
Sibling
Ancestors and descendants
Proper ancestors, proper descendants
Subtree
Leaf, interior node
Depth and height of a node
Height of a tree
Q9-14
The height of
a tree is the
height of its
root node.
Which is larger, the sum of
the heights or the sum of the
depths of all nodes in a tree?
A Binary Tree is either
◦ empty, or
◦ consists of:
a distinguished node called the root, which contains
an element, and
A left subtree TL, which is a binary tree
root
A right subtree TR, which is a binary tree
TL
TR
Let’s implement a
BinaryTree<T> class including
methods size(), height(),
duplicate(), and contains(T).