-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAVLTreeMain.java
More file actions
36 lines (35 loc) · 1.21 KB
/
AVLTreeMain.java
File metadata and controls
36 lines (35 loc) · 1.21 KB
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
public class AVLTreeMain {
public static void main(String[] args) {
AVLTree tree = new AVLTree();
try {
tree.insert(10);
tree.printTree(tree.root, "", false);
tree.insert(7);
tree.printTree(tree.root, "", false);
tree.insert(15);
tree.printTree(tree.root, "", false);
tree.insert(11);
tree.printTree(tree.root, "", false);
tree.insert(16);
tree.printTree(tree.root, "", false);
tree.insert(17);
tree.printTree(tree.root, "", false);
tree.insert(18);
tree.printTree(tree.root, "", false);
tree.insert(19);
tree.printTree(tree.root, "", false);
tree.insert(20);
tree.printTree(tree.root, "", false);
System.out.println(tree.height(tree.root));
tree.delete(17);
tree.printTree(tree.root, "", false);
tree.postOrder(tree.root);
System.out.println();
tree.preOrder(tree.root);
System.out.println();
tree.inOrder(tree.root);
} catch (Exception e) {
System.out.println(e);
}
}
}