+ 1
What's wrong with my shell sort?
It appears that my shell sort still needs one final pass, but I'm not sure what to change to achieve this. Could anyone point me in the right direction? https://code.sololearn.com/cMrvFWe4Cb9J/?ref=app
5 ответов
+ 2
Aha! That's what was missing, thank you very much.
+ 1
You set your gap to n / 2. What if that number is odd? It will automatically round down when stored into an integer. Maybe you desire that effect, but maybe that's what is happening. I haven't really tried a shell sort myself.
+ 1
Changing the division to odd doesn't help, unfortunately. No matter what, the final gap is the same. It's supposed to become a bubble sort after the gap is finished, but the sort stops just before the final pass for some reason.
+ 1
I suppose I could call my bubbleSort() function after my broken shellSort() function, lol.