-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBTree.java
59 lines (40 loc) · 1.28 KB
/
BTree.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
package Trees;
import java.util.List;
public interface BTree {
public static class TreeNode<T extends Comparable<T>> implements Comparable<T> {
T val;
TreeNode left, right;
public TreeNode() {
}
public TreeNode(T val) {
this.val = val;
}
public TreeNode(T val, TreeNode left, TreeNode right) {
this.val = val;
this.left = left;
this.right = right;
}
@Override
public int compareTo(T o) {
return this.val.compareTo(o);
}
@Override
public String toString() {
return "TreeNode{" +
"val=" + val +
", left=" + left +
", right=" + right +
'}';
}
}
public List<Object> inOrder(TreeNode node);
public List<Object> preOrder(TreeNode node);
public List<Object> postOrder(TreeNode node);
public List<List<Object>> levelOrder(TreeNode node);
public List<Object> leftView(TreeNode node);
public List<Object> rightView(TreeNode node);
public List<Object> topView(TreeNode node);
public List<Object> bottomView(TreeNode node);
public int height(TreeNode node);
public int size(TreeNode node);
}