ikg.adt.tree
Class Tree

java.lang.Object
  extended by ikg.adt.tree.Tree
All Implemented Interfaces:
java.io.Serializable

public class Tree
extends java.lang.Object
implements java.io.Serializable

Class with standard methods for handling binary trees

See Also:
Serialized Form

Field Summary
protected  TreeElement root
           
 
Constructor Summary
Tree()
          Constructor for the empty Tree object
Tree(java.lang.Object newContent)
          Constructor for the Tree object with newcontent as root
 
Method Summary
 void addLeftTree(Tree newLeft)
          Adds a tree to the Left attribute of the Tree object
 void addRightTree(Tree newRight)
          Adds a tree to the Right attribute of the Tree object
 int getDepth(Tree b)
          Gets the depth of the tree
 java.lang.String getInOrder()
          inOrder-Traversierung
 Tree getLeftTree()
          Gets the left attribute of the Tree object
 java.lang.String getPostOrder()
          postOrder-Traversierung
 java.lang.String getPreOrder()
          preOrder-Traversierung
 Tree getRightTree()
          Gets the right attribute of the Tree object
 java.lang.Object getRootItem()
          Gets the informationobject of root
 boolean isEmpty()
          Gets the empty attribute of the Tree object
 boolean isLeaf()
          Gets the leaf attribute of the Tree object
 java.lang.Object lastLeft(Tree b)
          returns the outmost left node of the tree
 java.lang.Object lastRight(Tree b)
          returns the outmost right node of the tree
 void loadTree(java.lang.String datName)
          The complete tree is loaded from a diskfile.
 int numberOfNodes(Tree b)
          determine the number of nodes of the tree
 void saveTree(java.lang.String datName)
          The complete tree is written to a diskfile.
 void setRootItem(java.lang.Object newInfo)
          sets the information of root to newInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected TreeElement root
Constructor Detail

Tree

public Tree()
Constructor for the empty Tree object


Tree

public Tree(java.lang.Object newContent)
Constructor for the Tree object with newcontent as root

Parameters:
newContent - object of any type
Method Detail

isEmpty

public boolean isEmpty()
Gets the empty attribute of the Tree object

Returns:
true if root ieq null else false

setRootItem

public void setRootItem(java.lang.Object newInfo)
sets the information of root to newInfo

Parameters:
newInfo - the new informationobject

getRootItem

public java.lang.Object getRootItem()
Gets the informationobject of root

Returns:
the informationobject

addRightTree

public void addRightTree(Tree newRight)
Adds a tree to the Right attribute of the Tree object

Parameters:
newRight - The tree to be added to the Right attribute

addLeftTree

public void addLeftTree(Tree newLeft)
Adds a tree to the Left attribute of the Tree object

Parameters:
newLeft - The tree to be added to the Left attribute

getRightTree

public Tree getRightTree()
Gets the right attribute of the Tree object

Returns:
The right value

getLeftTree

public Tree getLeftTree()
Gets the left attribute of the Tree object

Returns:
The left value

isLeaf

public boolean isLeaf()
Gets the leaf attribute of the Tree object

Returns:
true if the right and left tree are empty else false

numberOfNodes

public int numberOfNodes(Tree b)
determine the number of nodes of the tree

Parameters:
b - Tree
Returns:
Description of the Return Value

getDepth

public int getDepth(Tree b)
Gets the depth of the tree

Parameters:
b - Tree
Returns:
The depth value

lastRight

public java.lang.Object lastRight(Tree b)
returns the outmost right node of the tree

Parameters:
b - Tree
Returns:
the contents of the outmost right node

lastLeft

public java.lang.Object lastLeft(Tree b)
returns the outmost left node of the tree

Parameters:
b - Tree
Returns:
the contents of the outmost left node

saveTree

public void saveTree(java.lang.String datName)
The complete tree is written to a diskfile.

Parameters:
datName - name of the diskfile. If only the 8+3 name is specified the file is written in the actual directory; otherwise the name must be a absolute path

loadTree

public void loadTree(java.lang.String datName)
The complete tree is loaded from a diskfile.

Parameters:
datName - name of the diskfile. If only the 8+3 name is specified the file is written in the actual directory; otherwise the name must be a absolute path

getInOrder

public java.lang.String getInOrder()
inOrder-Traversierung

Returns:
A String with the contents of all informationobjects of the rootnodes

getPostOrder

public java.lang.String getPostOrder()
postOrder-Traversierung

Returns:
A String with the contents of all informationobjects of the rootnodes

getPreOrder

public java.lang.String getPreOrder()
preOrder-Traversierung

Returns:
A String with the contents of all informationobjects of the rootnodes