K
- class representing the key, should implement the Comparable class BSTnode<K>
extends java.lang.Object
Constructor and Description |
---|
BSTnode(K key)
Constructs a BST node with the given key and whose left and right
children are null.
|
BSTnode(K key,
BSTnode<K> leftChild,
BSTnode<K> rightChild)
Constructs a BST node with the given key, left child, and right child.
|
Modifier and Type | Method and Description |
---|---|
K |
getKey()
Returns the key for this BST node.
|
BSTnode<K> |
getLeft()
Returns the left child for this BST node.
|
BSTnode<K> |
getRight()
Returns the right child for this BST node.
|
void |
setKey(K newKey)
Changes the key for this node to the one given.
|
void |
setLeft(BSTnode<K> newLeft)
Changes the left child for this node to the one given.
|
void |
setRight(BSTnode<K> newRight)
Changes the right child for this node to the one given.
|
public BSTnode(K key)
key
- the key to store in this nodepublic K getKey()
public BSTnode<K> getLeft()
public BSTnode<K> getRight()
public void setKey(K newKey)
newKey
- the new keypublic void setLeft(BSTnode<K> newLeft)
newLeft
- the new left child