-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHollowHeapDriver.java
More file actions
84 lines (80 loc) · 3.34 KB
/
HollowHeapDriver.java
File metadata and controls
84 lines (80 loc) · 3.34 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
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
83
import java.util.Random;
/**
* Hollow Heap driver class.
* @author Courtney Dixon
* @version 11/9/2019
*/
public class HollowHeapDriver {
private static Random rando;
/**
* Main method.
* @param args command-line arguments
*/
public static void main(String[] args) {
int count = 0;
int nextOne = 0;
rando = new Random();
System.out.println("----------------------------------------------");
//System.out.println("");
Node e2 = new Node(2);
HollowHeap testHH = new HollowHeap(new HollowNode(3));
count++;
testHH.displayMin();
System.out.println("----------------------------------------------");
//System.out.println("");
testHH = testHH.insert(e2, e2.key, testHH);
count++;
testHH.displayMin();
System.out.println("----------------------------------------------");
//System.out.println("");
Node e3 = new Node(1);
testHH = testHH.insert(e3, e3.key, testHH);
count++;
testHH.displayMin();
System.out.println("----------------------------------------------");
//System.out.println("");
Node e4 = new Node(0);
testHH = testHH.insert(e4, e4.key, testHH);
count++;
testHH.displayMin();
System.out.println("----------------------------------------------");
//System.out.println("");
Node delNode = new Node(7);
testHH = testHH.insert(delNode, delNode.key, testHH);
count++;
testHH.displayMin();
System.out.println("----------------------------------------------");
testHH.printHHeap();
System.out.println("----------------------------------------------");
/*for (int i = 0; i < 20; i++) {
nextOne = rando.nextInt(25);
System.out.print(nextOne + " ");
testHH = testHH.insert(new Node(), nextOne, testHH);
count++;
}*/
//testHH.printHHeap();
System.out.println("\n----------------------------------------------");
System.out.printf("There should be %d HollowNode(s) in the heap"
+ " and there is(are) %d\n", count, testHH.getNumNodes());
System.out.println("----------------------------------------------");
Node currMin = testHH.findMin(testHH);
System.out.printf("The current minimum is %d\n", currMin.key);
System.out.println("----------------------------------------------");
System.out.println("----------------------------------------------");
System.out.printf("There should be %d HollowNode(s) in the heap"
+ " and there is(are) %d\n", count, testHH.getNumNodes());
testHH = testHH.delete(delNode, testHH);
count--;
System.out.printf("There should be %d HollowNode(s) in the heap"
+ " and there is(are) %d\n", count, testHH.getNumNodes());
testHH = testHH.deleteMin(testHH);
count--;
System.out.printf("There should be %d HollowNode(s) in the heap"
+ " and there is(are) %d\n", count, testHH.getNumNodes());
System.out.println("----------------------------------------------");
System.out.println(testHH.findMin(testHH));
testHH.printHHeap();
testHH = testHH.decreaseKey(e2, 1, testHH);
System.out.println(e2.key);
}
}