-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest_04.java
56 lines (44 loc) · 1.33 KB
/
Test_04.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
/* Test_xx.java
*
* Specific testcases, to see if students perform the required
* operations as designed. In *NO CASE* will we have duplicates in
* the heap at any given time, so that we don't have any ambiguity
* about going left or right when bubbling down. (Bubbling up
* doesn't have this problem.)
*
* Author: Russell Lewis
*/
import java.io.PrintWriter;
public class Test_04
{
public static void main(String[] args)
{
// this is the heap we'll test
Proj02_MaxHeap heap = new Proj02_MaxHeap(false);
// wrap System.out with a PrintWriter
PrintWriter out = new PrintWriter(System.out);
// any -99 values are "remove" operations. The rest are
// insert operations.
int[] inputs = {86,14,63,-7,48,-38,39, -99, -37,65,1,-13,
-99, -48,62,88,32, -99, 79, -99};
for (int val: inputs)
{
if (val == -99)
out.printf("removed %s\n", heap.removeMax());
else
{
heap.insert(val);
out.printf("inserted %s\n", val);
}
out.printf("Current heap: ");
heap.dump(out);
}
// this line is printed to allow the grading script to
// detect, easily, whether all of the tests completed. Do
// *NOT* attempt to falsify this line if your tests are
// broken - that is a violation of the Code of Academic
// Integrity!
out.printf("--- TESTCASE TERMINATED ---\n");
out.close();
}
}