public class Tree
extends java.lang.Object
Constructor and Description |
---|
Tree()
Empty constructor.
|
Tree(Node root)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
Node |
getRoot()
Returns the root of the
Tree . |
void |
insert(int data)
Inserts some data into the
Tree . |
boolean |
isEmpty()
Tests if the
Tree is empty. |
void |
print()
Prints the
Tree . |
public Tree()
Tree
with an empty rootpublic Tree(Node root)
Tree
with the specified
Node
as the rootpublic Node getRoot()
Tree
.public boolean isEmpty()
Tree
is empty.true
if the root is null
public void insert(int data)
Tree
.
We traverse down the Tree
recursively following the rules of
a BST.data
- the data to insertpublic void print()
Tree
.
First, the right sub-tree of the current Node
is output,
then the Node
itself, then the left sub-tree, recursively!