Timeline for Max heap implementation in Kotlin
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 16, 2016 at 1:30 | vote | accept | Andrew Sun | ||
| Mar 15, 2016 at 15:57 | comment | added | mfulton26 | @AndrewSun Awesome. In the future, you might even include your tests in the code review. I personally find no better documentation for main code than test code. | |
| Mar 15, 2016 at 14:23 | comment | added | Andrew Sun |
Ahh, I see the problem, thanks. I actually did have some tests (including removing all items from the heap), I think what happened is that assertions weren't even enabled :-p I agree that not calling siftDown when the heap is empty would be the best solution, so the assertion would still work in all other cases.
|
|
| Mar 15, 2016 at 13:52 | history | edited | mfulton26 | CC BY-SA 3.0 |
Suggest different verbs more consistent with the Java Collections Framework
|
| Mar 15, 2016 at 13:11 | comment | added | mfulton26 |
@AndrewSun I suggest creating some unit tests. :-) That is how I caught it although after inspecting the code closer my suggested fix was probably not the best solution. As such, I've updated my #3 to simply state the problem. The best fix might be to only call siftDown if size > 1. An alternative would be to move the assertion to after the i >= size / 2 check. I'm sure there are other ways to fix it as well.
|
|
| Mar 15, 2016 at 13:09 | history | edited | mfulton26 | CC BY-SA 3.0 |
Updated #3 to not suggest a fix
|
| Mar 15, 2016 at 2:30 | comment | added | Andrew Sun |
Hmm, under what conditions can i == size be true?
|
|
| Mar 14, 2016 at 13:37 | review | First posts | |||
| Mar 14, 2016 at 13:45 | |||||
| Mar 14, 2016 at 13:28 | history | answered | mfulton26 | CC BY-SA 3.0 |