Created
December 7, 2012 21:59
-
-
Save bilalq/4236861 to your computer and use it in GitHub Desktop.
The node for the BST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TreeNode | |
{ | |
private Comparable value; | |
TreeNode left, right; | |
public TreeNode(Comparable initValue) | |
{ | |
value = initValue; | |
left = null; | |
right = null; | |
} | |
public TreeNode(Comparable initValue, TreeNode initLeft, TreeNode initRight) | |
{ | |
value = initValue; | |
left = initLeft; | |
right = initRight; | |
} | |
public Comparable getValue() | |
{ | |
return value; | |
} | |
public TreeNode getLeft() | |
{ | |
return left; | |
} | |
public TreeNode getRight() | |
{ | |
return right; | |
} | |
public void setValue(Comparable theNewValue) | |
{ | |
value = theNewValue; | |
} | |
public void setLeft(Comparable theNewLeft) | |
{ | |
this.left = new TreeNode(theNewLeft); | |
} | |
public void setRight(Comparable theNewRight) | |
{ | |
right = new TreeNode(theNewRight); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Javas!