Graph | Purpose of test |
---|---|
kruTest1 | General tree |
kruTest2 | General tree |
kruTest3 | Tree is already a MST / all edges come from a single vertex |
Explanations can be found here.
No explanation on website, had to derive the MST by myself.
Note: Second tree has two solutions for the last edge -> I added 2 different result files to account for this, if you result if any of these, you should be fine.
If you add new test cases, you must update the following variables:
int[][] weights;
int[][] deadlines;
int[][] expected;
int[] expectedSum; // Sum of the weights of all completed assignments.
The extra array expectedSum
was introduced to account for multiple correct solutions.
This is pretty self-explanatory. You must compile Greedy_Tester.java
along with your solution to the algorithm.
$ javac Greedy_Tester.java
$ java Greedy_Tester
Sample output could look like:
Test 1: PASS
------------------------------
Expected: [1, 2, 0]
Your solution: [1, 2, 0]
Test 2: PASS
------------------------------
Expected: [0, 1, 2, 3]
Your solution: [0, 1, 2, 3]
Test 3: PASS
------------------------------
Expected: [0, 2, 1, 3]
Your solution: [0, 2, 1, 3]
Test 4: PASS
------------------------------
Expected: [5, 6, 3, 0, 1, 7]
Your solution: [5, 6, 3, 0, 1, 7]
Test 5: PASS
------------------------------
Expected: [3, 5, 2, 4, 0, 7, 6]
Your solution: [3, 5, 2, 4, 0, 7, 6]
Test 6: PASS
------------------------------
Expected: [1]
Your solution: [1]
You passed 6/6 tests!
N.B. Some test cases may have multiple solutions, so your solution (while valid) may not match the expected solution.
Feel free to fork the repository and add more test cases.