problems
problems copied to clipboard
Tideman: check50 bug
I realized that I am able to write code that would give me a wrong output or even cause an overflow.
Changing the code in line 147 to if (n == 0)
would potentially skip one of the pairs and not save them which gives two winners as an output when tested on the first example in the instructions while it is only supposed to be one winner.
Changing the code in line 228 to int border = ((last - first) / 2);
would have the effect that unsorted arrays with more than 4 elements would cause an overflow because the recursion will not be stopped for the upper half of the array.
Both of these get full credit from check50. I am not sure what exactly is happening in the check50 algorithm which is why I could not look into it any further. They might be more such cases.
tideman.txt
I've found a similar scenario. I filled out my sort_pairs
function like this but going back and looking at it again it only performs a single iteration of Bubble Sort. This should later affect the order pairs are added to the adjacency matrix making the entire output wrong but check50 gives full marks.
sort_pairs_incorrect.txt