Java Reference
In-Depth Information
AbstractTree<E>
m
0
TreeNode<E>
BST<E extends Comparable<E>>
#element: E
#left: TreeNode<E>
#right: TreeNode<E>
#root: TreeNode<E>
#size: int
The root of the tree.
The number of nodes in the tree.
+BST()
+BST(objects: E[])
+path(e: E):
java.util.List<TreeNode<E>>
Creates a default BST.
Creates a BST from an array of elements.
Returns the path of nodes from the root leading to
the node for the specified element. The element
may not be in the tree.
1
Link
F IGURE 25.8
The BST class defines a concrete BST.
9
/** Delete the specified element from the tree.
10
* Return true if the element is deleted successfully. */
11
public boolean delete(E e);
delete
12
13
/** Inorder traversal from the root*/
14
public void inorder();
inorder
15
16
/** Postorder traversal from the root */
17
public void postorder();
postorder
18
19
/** Preorder traversal from the root */
20
public void preorder();
preorder
21
22
/** Get the number of nodes in the tree */
23
public int getSize();
getSize
24
25
/** Return true if the tree is empty */
26
public boolean isEmpty();
isEmpty
27 }
L ISTING 25.4
AbstractTree.java
1 public abstract class AbstractTree<E>
2 implements Tree<E> {
3 @Override /** Inorder traversal from the root*/
4 public void inorder() {
5 }
6
7 @Override /** Postorder traversal from the root */
8 public void postorder() {
9 }
10
11 @Override /** Preorder traversal from the root */
12 public void preorder() {
13 }
14
15 @Override /** Return true if the tree is empty */
abstract class
default inorder
implementation
default postorder
implementation
default preorder
implementation
 
 
Search WWH ::




Custom Search