-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryTreeADT.java
84 lines (71 loc) · 2.24 KB
/
BinaryTreeADT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* BinaryTreeADT defines the interface to a binary tree data structure.
*
* @author Dr. Lewis
* @author Dr. Chase
* @version 1.0, 8/19/08
*/
import java.util.Iterator;
public interface BinaryTreeADT<T>
{
/**
* Returns a reference to the root element
*
* @return a reference to the root
*/
public BinaryTreeNode<T> getRoot();
/**
* @return the element at the root
*/
public boolean isEmpty();
/**
* Returns the number of elements in this binary tree.
*
* @return the integer number of elements in this tree
*/
public int size();
/**
* Returns true if the binary tree contains an element that matches
* the specified element and false otherwise.
*
* @param targetElement the element being sought in the tree
* @return true if the tree contains the target element
*/
public boolean contains (T targetElement);
/**
* Returns a reference to the specified element if it is found in
* this binary tree. Throws an exception if the specified element
* is not found.
*
* @param targetElement the element being sought in the tree
* @return a reference to the specified element
*/
public T find (T targetElement);
/**
* Returns the string representation of the binary tree.
*
* @return a string representation of the binary tree
*/
public String toString();
/**
* Performs an inorder traversal on this binary tree by calling an
* overloaded, recursive inorder method that starts with the root.
*
* @return an iterator over the elements of this binary tree
*/
public Iterator<T> iteratorInOrder();
/**
* Performs a preorder traversal on this binary tree by calling an
* overloaded, recursive preorder method that starts with the root.
*
* @return an iterator over the elements of this binary tree
*/
public Iterator<T> iteratorPreOrder();
/**
* Performs a postorder traversal on this binary tree by calling an
* overloaded, recursive postorder method that starts with the root.
*
* @return an iterator over the elements of this binary tree
*/
public Iterator<T> iteratorPostOrder();
}