-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVL_TreeClassMain.java
82 lines (69 loc) · 2.69 KB
/
AVL_TreeClassMain.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
package p9_package;
public class AVL_TreeClassMain
{
public static void main(String[] args)
{
AVL_TreeClass testClass = new AVL_TreeClass();
// balanced case
testClass.insert( 'M' );
testClass.insert( 'G' );
testClass.insert( 'R' );
testClass.insert( 'B' );
testClass.insert( 'J' );
testClass.insert( 'P' );
testClass.insert( 'U' );
testClass.insert( 'A' );
testClass.insert( 'C' );
testClass.insert( 'H' );
testClass.insert( 'L' );
testClass.insert( 'N' );
testClass.insert( 'Q' );
testClass.insert( 'S' );
testClass.insert( 'X' );
// unbalanced case
testClass.insert( 'X' );
testClass.insert( 'S' );
testClass.insert( 'Q' );
testClass.insert( 'N' );
testClass.insert( 'L' );
testClass.insert( 'H' );
testClass.insert( 'C' );
testClass.insert( 'A' );
testClass.insert( 'U' );
testClass.insert( 'P' );
testClass.insert( 'J' );
testClass.insert( 'B' );
testClass.insert( 'R' );
testClass.insert( 'G' );
testClass.insert( 'M' );
// Right right cases
testClass.insert( 'A' );
testClass.insert( 'B' );
testClass.insert( 'C' );
testClass.insert( 'D' );
testClass.insert( 'E' );
testClass.insert( 'F' );
testClass.insert( 'G' );
testClass.insert( 'H' );
testClass.insert( 'I' );
testClass.insert( 'J' );
testClass.insert( 'K' );
// Left left cases
testClass.insert( 'Z' );
testClass.insert( 'Y' );
testClass.insert( 'X' );
testClass.insert( 'W' );
testClass.insert( 'V' );
testClass.insert( 'U' );
testClass.insert( 'T' );
testClass.insert( 'S' );
testClass.insert( 'R' );
testClass.insert( 'Q' );
testClass.insert( 'P' );
System.out.println( "\nTree height: " + testClass.findTreeHeight() );
System.out.println( "\nTree Data Display:" );
testClass.displayTreeStructure();
System.out.println( "\nList Data Display:" );
testClass.inOrderDisplay();
}
}