Answer the question
In order to leave comments, you need to log in
How does the ShellSort algorithm work?
public static void shellSort(int[] array) {
int step = array.length / 2;
while (step != 0) {
for (int i = 0; i < step; i++) {
//Как может работать сл-ий цикл, если тут j в последствии выходит за индексные рамки массива?
for (int j = i + step; j < array.length; j += step) {
int temp = array[j];
int k;
//Тот же вопрос
for (k = j - step; k >= 0 && array[k] > temp; k -= step) {
array[k + step] = array[k];
}
array[k + step] = temp;
}
}
step = step / 2;
}
}
Answer the question
In order to leave comments, you need to log in
How does it go beyond the index scope of the array if the loop condition is
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question