Closed Lokakaaa closed 3 years ago
cum
is not reset to zero after sort one input array. That means in the next invoked sort(), cum is not 0
and may lead to unexpected errors.
void testRobustness(AbstractSort<Integer> engine) {
final int iter = 100;
final int size = 1000;
final Random rand = new Random();
Integer[] original, sorted;
for (int i = 0; i < iter; i++) {
original = Stream.generate(() -> rand.nextInt(size)).limit(size).toArray(Integer[]::new);
sorted = Arrays.copyOf(original, size);
engine.sort(original);
Arrays.sort(sorted);
assertArrayEquals(original, sorted);
}
}
engine
would be tested with multiple arrays. I highly doubt errors are introduced due to that cum
not be reset.
Also, I am not trying to say eliminate cum
issue would lead your codes perfect. But this is at least one error I noticed at first trial.
I have tested my code using different datasets and they all went well,
I tested your codes, it succeeded for one input array. However, not able to deal with multiple arrays need to be tested.
You are right, my problem is solved. Thank you so much!
I have tested my code using different datasets and they all went well,
I tested your codes, it succeeded for one input array. However, not able to deal with multiple arrays need to be tested.
Replace
#
in the title with the appropriate quiz number. I have tested my code using different datasets and they all went well, and I can also print out the array generated by the robustness test in a sorted order(using print array added by myself). However, I cannot pass the robustness test. Can you please help me find if anything is wrong?Here is the link to my code https://github.com/Lokakaaa/dsa-java/blob/master/src/main/java/edu/emory/cs/sort/distribution/RadixSortQuiz.java Thank you so much.