public class BSTNode<K>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
balanceFactor
Balance factor for this node, which is equal to the height of its left
subtree minus the height of its right subtree.
|
private int |
height
The height of a node is the length of the path from that node to
the farthest leaf.
|
private K |
key
Key value
|
private BSTNode<K> |
left
Left child
|
private BSTNode<K> |
right
Right child
|
Constructor and Description |
---|
BSTNode(K k)
Constructs a new leaf node containing k.
|
Modifier and Type | Method and Description |
---|---|
int |
getBalanceFactor()
Get this node's balance factor.
|
int |
getHeight()
Get this node's height.
|
K |
getKey()
Get this node's key.
|
BSTNode<K> |
getLeftChild()
Get this node's left child.
|
BSTNode<K> |
getRightChild()
Get this node's right child.
|
void |
setBalanceFactor(int bf)
Set this node's balance factor.
|
void |
setHeight(int h)
Set this node's height.
|
void |
setLeftChild(BSTNode<K> l)
Set this node's left child.
|
void |
setRightChild(BSTNode<K> r)
Set this node's right child.
|
private K key
private int height
private int balanceFactor
public BSTNode(K k)
k
- the keypublic K getKey()
public BSTNode<K> getRightChild()
public int getHeight()
public int getBalanceFactor()
public void setLeftChild(BSTNode<K> l)
l
- the left childpublic void setRightChild(BSTNode<K> r)
r
- the right childpublic void setHeight(int h)
h
- the heightpublic void setBalanceFactor(int bf)
bf
- the balance factor