-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.java
More file actions
48 lines (38 loc) · 1.26 KB
/
Interface.java
File metadata and controls
48 lines (38 loc) · 1.26 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
37
38
39
40
41
42
43
44
45
46
47
48
public class Interface {
public static void main(String[] args){
test();
System.out.println();
stressTest();
}
public static void test(){
BinaryTree<Integer> myTree = new BinaryTree<Integer>();
int[] items = new int[] {5, 4, 7, 0, 6, 20, 3, 10, 30, 9, 15, 21, 33};
for(int i : items){
System.out.println("Adding: " + i);
myTree.add(i);
System.out.println(myTree.toString());
System.out.println("Size: " + myTree.size());
}
System.out.println();
for(int i : items){
System.out.println("Getting " + i);
System.out.println(myTree.get(i));
}
System.out.println();
for(int i : items){
System.out.println("Removing " + i);
myTree.remove(i);
System.out.println(myTree.toString());
}
}
public static void stressTest(){
BinaryTree<Integer> tree = new BinaryTree<Integer>();
int runfor = 10000000;
System.out.println("Adding and removing " + runfor + " times");
for(int i = 0; i < runfor; i++){
tree.add(i);
tree.remove(i);
}
System.out.println("Done.");
}
}