Collections-Trees, java framework notes
Collections-Trees, java framework notes
Intro to Trees
List positives:
◦ The only way to help people improve!
Introduction to trees
A “factory
method”
Q3
ListIterator<E> adds:
ag can be any Collection of Integers
containsAll(Collection other)
removeAll(Collection other)
retainAll(Collection other)
toArray()
Handy java.util.Arrays utility methods:
See
Collections
for similar
methods on
Lists
Q4
weiss.util
◦ Shows "bare bones" possible implementations of
some of the classes in java.util
◦ Illustrates (just) the essence of what is involved in
implementation
weiss.nonstandard
◦ Some other data structures, not found in
java.util
◦ Some alternate approaches to some classes that are
also in weiss.util
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.
TL
TR
Let’s implement a
BinaryTree<T> class including
methods size(), height(),
duplicate(), and contains(T).