|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectintroExam.BinarySearchTree.BST
ExtendedBST
These methods are the candidates for the BST question
Nested Class Summary |
Nested classes inherited from class introExam.BinarySearchTree.BST |
BST.BSTNode |
Field Summary |
Fields inherited from class introExam.BinarySearchTree.BST |
root |
Constructor Summary | |
ExtendedBST()
|
Method Summary | |
int |
balancedFactorOfNode(java.lang.Comparable value)
This method returns balanced factor of a given node with value If the node does not exists, return -1 Balanced Factor is defined as the absolute value of the difference in heights between left and right subtrees of the node. |
ExtendedBST |
cloneTree()
Creates and returns an exact copy of the tree. |
boolean |
isPerfect()
Returns true if, and only if, all leaves of the tree are at the same level (are the same distance from the root) and the tree has the maximum number of nodes for its depth (each node has exactly 0 or two children), and false otherwise. |
int |
maxLeafLevel()
Returns the level of the leaf that is farthest from the top (root) of the tree. |
int |
minLeafLevel()
Returns the level of the leaf that is closest to the top (root) of the tree. |
void |
printLeavesAtLevel(int level)
Prints to the console a list of all items organized at the specified level of the tree. |
void |
printPath(java.lang.Comparable keyValue)
Prints the value at each node between and including the root and the supplied keyValue. |
Methods inherited from class introExam.BinarySearchTree.BST |
insert, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ExtendedBST()
Method Detail |
public ExtendedBST cloneTree()
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns null.
public int minLeafLevel()
The root is considered to be at level 0.
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns -1
public int maxLeafLevel()
The root is considered to be at level 0.
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns -1
public boolean isPerfect()
This method does not change any of the items or the structure of the original tree.
In the event of an error, it returns false
public void printPath(java.lang.Comparable keyValue)
This method does not change any of the items or the structure of the original tree.
It can print the nodes in any order, but cannot use a collection class.
public void printLeavesAtLevel(int level)
This method does not change any of the items or the structure of the original tree.
It can print all the nodes at the specified level
public int balancedFactorOfNode(java.lang.Comparable value)
This method does not change any of the items or the structure of the original tree.
Print the absolute value of the differences between heights of left and right subtrees. If the node does not exists, return -1
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |