mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-02-11 05:44:31 +00:00
the array index could be -1 #40
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @VincentGogo on GitHub (Jan 9, 2020).
807abcd0e8/sorting/gnome_sort.c (L9)@StepfenShawn commented on GitHub (Apr 18, 2020):
Hi @VincentGogo !
This is gnome_sort's pseudo code:
But you said that the array index can be - 1, I don't quite understand why to do this,Could you provide the running result after modifying the code?
Thank you!
@VincentGogo commented on GitHub (Apr 18, 2020):
@StepfenShawn The pseudo code is right, The C code at line 9 should be
if ( pos == 0 || numbers[pos] >= numbers[pos-1]@StepfenShawn commented on GitHub (Apr 19, 2020):
OK, I see. I'll fix it soon. Thank you!