For my method, partition, for my quick sort, it is okay when I run it. However, whenever I upload on the project submit page, the testing returns negative result for the design of this code. which is like
static long partition(DataArray array, long l, long r, Record pivot)
throws Exception {
do { // Move bounds inward until they meet
while (array.get(++l).compareTo(pivot) < 0)
;
this line, i get.. three errors...
Error [Checkstyle]: -2 This statement is just a ';' and, therefore, does nothing. You may have added a ';' in an inappropriate location (like after an if or a for loop). See if you are missing code or just delete the extra ';'.
Error [PMD]: -1 (limit exceeded) It is a good idea to always enclose the code in the body of a while loop in braces. It helps to reduce the likelihood of errors.
Error [PMD]: 0 (limit exceeded) The body of this while loop is empty. Make sure you do not have a semicolon (;) after the while by mistake. If you do not need to do anything in the body of the loop you can probably omit the loop entirely.
while ((r != 0) && ((array.get(--r).compareTo(pivot) > 0)))
;
and another three errors here
Error [Checkstyle]: -2 This statement is just a ';' and, therefore, does nothing. You may have added a ';' in an inappropriate location (like after an if or a for loop). See if you are missing code or just delete the extra ';'.
Error [PMD]: 0 (limit exceeded) It is a good idea to always enclose the code in the body of a while loop in braces. It helps to reduce the likelihood of errors.
Error [PMD]: 0 (limit exceeded) The body of this while loop is empty. Make sure you do not have a semicolon (;) after the while by mistake. If you do not need to do anything in the body of the loop you can probably omit the loop entirely.
swap(array, l, r); // Swap out-of-place values
}
while (l < r); // Stop when they cross
swap(array, l, r); // Reverse last, wasted swap
return l; // Return first position in right partition
}
I know this testing server is wired, so I get points off from this kind of reason. How can I re-write this code that will perform the same thing?