-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain Method.txt
More file actions
38 lines (26 loc) · 1.47 KB
/
Main Method.txt
File metadata and controls
38 lines (26 loc) · 1.47 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 static void main(String[] args)
{
String values1[]={"Sydney", "Beijing","Shanghai", "New York", "Tokyo", "Berlin",
"Athens", "Paris", "London", "Cairo"};
int keys1[]={20, 8, 5, 30, 22, 40, 12, 10, 3, 5};
String values2[]={"Fox", "Lion", "Dog", "Sheep", "Rabbit", "Fish"};
int keys2[]={40, 7, 5, 32, 20, 30};
/* Create the first AVL tree with an external node as the root and the
default comparator */
AVLTree<Integer, String> tree1=new AVLTree<Integer, String>();
// Insert 10 nodes into the first tree
for ( int i=0; i<10; i++)
tree1.insert(keys1[i], values1[i]);
/* Create the second AVL tree with an external node as the root and the
default comparator */
AVLTree<Integer, String> tree2=new AVLTree<Integer, String>();
// Insert 6 nodes into the tree
for ( int i=0; i<6; i++)
tree2.insert(keys2[i], values2[i]);
ExtendedAVLTree.print(tree1);
ExtendedAVLTree.print(tree2);
ExtendedAVLTree.print(ExtendedAVLTree.clone(tree1));
ExtendedAVLTree.print(ExtendedAVLTree.clone(tree2));
ExtendedAVLTree.print(ExtendedAVLTree.merge(ExtendedAVLTree.clone(tree1),
ExtendedAVLTree.clone(tree2)));
}