|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This interface describes one interpretation of an object oriented versions of the recursive binary tree found in McCarthey's LISP. Specification: a binary tree, T, is (1) empty, T = (), or (2) T = (r,(L,R)) where r is the root of the tree and L and R are (possibly empty) binary trees.
| Method Summary | |
java.lang.Object |
getRoot()
Returns a reference to the root of the current tree. |
void |
graft(RecursiveBinaryTree T)
Replace the current tree by T. |
boolean |
isEmpty()
Returns true if and only if the current tree is empty. |
RecursiveBinaryTree |
leftSubtree()
Returns a reference to the left subtree of the current tree. |
RecursiveBinaryTree |
prune()
Return reference to the current tree, then make current tree empty. |
RecursiveBinaryTree |
rightSubtree()
Returns a reference to the right subtree of the current tree. |
void |
setRoot(java.lang.Object obj)
Modify the root of the current tree. |
java.lang.String |
toString()
Returns a string representation of the tree. |
| Method Detail |
public boolean isEmpty()
public RecursiveBinaryTree leftSubtree()
public RecursiveBinaryTree rightSubtree()
public java.lang.Object getRoot()
public void setRoot(java.lang.Object obj)
obj - The new root of the current treepublic void graft(RecursiveBinaryTree T)
T - becomes the current treepublic RecursiveBinaryTree prune()
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||