+ 2
Can you check it?
I shared a code about gnome sort. Can you check if it's right? It's my homework.
3 odpowiedzi
+ 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++;
}
}
}
+ 1
Thank you for your helping 😄
0
Ebru selam