E - The type of element that the BinarySearchTree will hold. Please note that E must implement the
KeyElementInterface or some super class of E must implement the KeyElementInterface.K - The type of key that all elements must contain. Please note that K must implement the
Comparable interface or some super class of K must implement the Comparable interface.public class TreeNode<E extends KeyedElementInterface<K>,K extends java.lang.Comparable<? super K>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private E |
element
This instance variable holds the element that is in the BinarySearchTree
|
private TreeNode<E,K> |
leftChild
This instance variable is a reference to the left child of the current
TreeNode |
private TreeNode<E,K> |
parent
This instance variable is a reference to the parent of the current
TreeNode |
private TreeNode<E,K> |
rightChild
This instance variable is a reference to the right child of the current
TreeNode |
| Constructor and Description |
|---|
TreeNode(E element)
Constructor for the
TreeNode. |
| Modifier and Type | Method and Description |
|---|---|
E |
getElement()
Getter for
element instance variable. |
TreeNode<E,K> |
getLeftChild()
Getter for
leftChild instance variable. |
TreeNode<E,K> |
getParent()
Getter for
parent instance variable. |
TreeNode<E,K> |
getRightChild()
Getter for
rightChild instance variable. |
void |
setElement(E element)
Setter for
element instance variable. |
void |
setLeftChild(TreeNode<E,K> leftChild)
Setter for
leftChild instance variable. |
void |
setParent(TreeNode<E,K> parent)
Setter for
parent instance variable. |
void |
setRightChild(TreeNode<E,K> rightChild)
Setter for
rightChild instance variable. |
private E extends KeyedElementInterface<K> element
private TreeNode<E extends KeyedElementInterface<K>,K extends java.lang.Comparable<? super K>> leftChild
TreeNodeprivate TreeNode<E extends KeyedElementInterface<K>,K extends java.lang.Comparable<? super K>> rightChild
TreeNodepublic TreeNode(E element)
TreeNode. This constructor should set leftChild,
rightChild, and parent to null.element - This is parameter is used to set the element instance variable.public TreeNode<E,K> getLeftChild()
leftChild instance variable.leftChild of the current TreeNodepublic void setLeftChild(TreeNode<E,K> leftChild)
leftChild instance variable.leftChild - The new leftChild of the current TreeNodepublic TreeNode<E,K> getRightChild()
rightChild instance variable.rightChild of the current TreeNodepublic void setRightChild(TreeNode<E,K> rightChild)
rightChild instance variable.rightChild - The new rightChild of the current TreeNodepublic TreeNode<E,K> getParent()
parent instance variable.parent of the current TreeNodepublic void setParent(TreeNode<E,K> parent)
parent instance variable.parent - The new parent of the current TreeNodepublic E getElement()
element instance variable.element of the current TreeNodepublic void setElement(E element)
element instance variable.element - The new element of the current TreeNode