Timeline for Palindromes in C
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 2, 2015 at 4:59 | comment | added | niyasc | @JS1 I used gcc without any optimization. | |
Dec 1, 2015 at 18:26 | comment | added | JS1 | @Angew And I don't mean to say that bubblesort is better than quicksort. Just that for the same algorithm, writing it in a clearer way is better, because a lot of bugs can arise from writing unclear/tricky code, and bugs are a lot worse than small performance degradations. | |
Dec 1, 2015 at 18:16 | comment | added | JS1 | @niyasc With what compiler and optimization level? On my compiler it was the same. (gcc with and without optimizations) | |
Dec 1, 2015 at 18:09 | comment | added | JS1 | @Angew I've learned a long time ago that readability/understandability beats performance every time. In my head, I had to read over the OP's loop many times before I could argue to myself that it was correct. Maybe it had to do with the odd positions of the ++ and -- rather than the pointers themselves, I don't know. All I know is that I could visualize the indexed version much easier than the pointer version. | |
Dec 1, 2015 at 12:13 | comment | added | Angew is no longer proud of SO | In my view, going from pointers to indices is actually less idiomatic C, and relies more on the compiler optimisations to keep performance. | |
Dec 1, 2015 at 9:36 | comment | added | niyasc |
In performance point of view, your solution is taking more time. OP's solution takes 0.017 in my machine. While your solution takes 0.026
|
|
Dec 1, 2015 at 8:11 | history | edited | JS1 | CC BY-SA 3.0 |
Added more explanation for const.
|
Dec 1, 2015 at 1:51 | history | answered | JS1 | CC BY-SA 3.0 |