-
-
Notifications
You must be signed in to change notification settings - Fork 359
/
Copy pathMainClass.java
31 lines (22 loc) · 1.01 KB
/
MainClass.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
//submitted by xam4lor
public class MainClass {
public static void main(String[] args) {
System.out.println("Creating Tree");
Tree tree = new Tree(3, 3);
System.out.println("Using recursive DFS :");
tree.dfsRecursive();
System.out.println("Using stack-based DFS :");
tree.dfsStack();
System.out.println("Using queue-based BFS :");
tree.bfsQueue();
System.out.println("Using post-order recursive DFS :");
tree.dfsRecursivePostOrder();
// Uncommenting the following 2 lines will result in an exception thrown because at least one Node of the Tree has more than 2 children and therefor a DFSRecursiveInorderBinary doesn't work.
System.out.println("Using in-order binary recursive DFS : (fail)");
tree.dfsRecursiveInOrderBinary();
tree = new Tree(3, 2);
System.out.println("Using in-order binary recursive DFS : (succeed)");
tree.dfsRecursiveInOrderBinary();
System.out.println("");
}
}