public abstract class AbstractBinaryTree<E> extends AbstractTree<E> implements BinaryTree<E>
Constructor and Description |
---|
AbstractBinaryTree() |
Modifier and Type | Method and Description |
---|---|
Iterable<Position<E>> |
children(Position<E> p)
Returns an iterable collection of the Positions representing p's children.
|
Iterable<Position<E>> |
inorder()
Returns an iterable collection of positions of the tree, reported in inorder.
|
int |
numChildren(Position<E> p)
Returns the number of children of Position p.
|
Iterable<Position<E>> |
positions()
Returns an iterable collection of the positions of the tree using inorder traversal
|
Position<E> |
sibling(Position<E> p)
Returns the Position of p's sibling (or null if no sibling exists).
|
breadthfirst, depth, height, isEmpty, isExternal, isInternal, isRoot, iterator, postorder, preorder, size
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
left, right
isEmpty, isExternal, isInternal, isRoot, iterator, parent, root, size
public Position<E> sibling(Position<E> p)
sibling
in interface BinaryTree<E>
p
- A valid Position within the treeIllegalArgumentException
- if p is not a valid Position for this treepublic int numChildren(Position<E> p)
numChildren
in interface Tree<E>
numChildren
in class AbstractTree<E>
p
- A valid Position within the treeIllegalArgumentException
- if p is not a valid Position for this tree.public Iterable<Position<E>> children(Position<E> p)
children
in interface Tree<E>
p
- A valid Position within the treeIllegalArgumentException
- if p is not a valid Position for this tree.public Iterable<Position<E>> inorder()