|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.tree.RightThreadedBinaryTree<T>
T
- the base type of the values stored by the BinaryTree. Must be
Comparable.public class RightThreadedBinaryTree<T extends java.lang.Comparable>
Unbalanced right-threaded binary tree. Duplicates are allowed. The right child of a node in the tree is guaranteed to have its value be greater than or equal to its parent. There is an artificial 'root' node whose left child is the real root of the tree. The reason for this artificial node is to simplify the algorithm and to enable the right-most node of the tree to have something to point to!
Constructor Summary | |
---|---|
RightThreadedBinaryTree()
Default BinaryTree constructor. |
Method Summary | |
---|---|
void |
accept(IVisitor visitor)
Accept a visitor for a inorder traversal. |
RightThreadedBinaryNode<T> |
getRoot()
Return the root of the tree. |
java.util.Iterator<T> |
inorder()
Use in-order traversal over the tree. |
void |
insert(T value)
Insert the value into its proper location in the Binary tree. |
java.util.Iterator<T> |
iterator()
Provide useful in-order iteration over the values of the Binary Tree. |
boolean |
member(T value)
Determine if the given value occurs in the tree. |
java.util.Iterator<T> |
postorder()
Use post-order traversal over the tree. |
java.util.Iterator<T> |
preorder()
Use pre-order traversal over the tree. |
boolean |
remove(T value)
Remove the value from the tree. |
protected void |
setRoot(RightThreadedBinaryNode<T> newRoot)
Helper method to properly set the root for the tree. |
java.lang.String |
toString()
Create string representation of the Tree. |
boolean |
validateArtificialRoot()
Placed here for the purpose of testing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RightThreadedBinaryTree()
Method Detail |
---|
protected void setRoot(RightThreadedBinaryNode<T> newRoot)
newRoot
- public RightThreadedBinaryNode<T> getRoot()
public boolean member(T value)
value
- non-null desired value to search for
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public boolean remove(T value)
value
- non-null value to be removed
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public void insert(T value)
value
- non-null value to be added into the tree.
java.lang.IllegalArgumentException
- if value is null
java.lang.ClassCastException
- if the specified object's type prevents it
from being compared to this object.public java.lang.String toString()
toString
in class java.lang.Object
public void accept(IVisitor visitor)
public java.util.Iterator<T> inorder()
public java.util.Iterator<T> preorder()
public java.util.Iterator<T> postorder()
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T extends java.lang.Comparable>
public boolean validateArtificialRoot()
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |