+ 2

Can you check it?

I shared a code about gnome sort. Can you check if it's right? It's my homework.

8th May 2020, 11:18 PM
Ebru
Ebru - avatar
4 ответов
+ 2
While, yes, this is a completely valid gnome sort. Here is your method with a couple of minor code optimizations. static void gnomeSort(int[] arr) { int series = 1; int temp = 0; while (series < arr.Length) { if (arr[series] >= arr[series - 1]) series++; else { temp = arr[series]; arr[series] = arr[series - 1]; arr[series - 1] = temp; series--; if (series == 0) series++; } } }
9th May 2020, 12:28 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thank you for your helping 😄
9th May 2020, 12:20 PM
Ebru
Ebru - avatar
0
Ebru selam
10th May 2020, 8:59 AM
Bossan Amangeldiyewa