Also eins vorneweg: dass es ein Sortierverfahren ist, weiß ich, und dass es in diesem Forum "nur" um Webprogrammierung geht, auch. Vielleicht kennt ihr euch allerdings trotzdem ein wenig mit Java aus
Was bedeuten die eckigen Klammern, wofür steht "array.length", wozu ist das "%"-Zeichen gut, u.v.m.
public void Shell_Sort(int[] array) {
int t = 0;
if (array.length % 2 == 0)
t = array.length >> 1;
else
t = (array.length >> 1) + 1;
while (t >= 1) {
for (int i = t,temp = 0; i < array.length; i++) {
for (int j = i - t; j >= 0; j =j - t) {
if (array[j] > array[j + t]) {
temp = array[j];
array[j] = array[j + t];
array[j + t] = temp;
}
}
}
if (t == 1)
break;
if (t % 2 == 0)
t = t >> 1;
else
t = (t >> 1) + 1;
}
}
Ich bedanke mich im vorraus !
Gruß
Michi09
Was bedeuten die eckigen Klammern, wofür steht "array.length", wozu ist das "%"-Zeichen gut, u.v.m.
public void Shell_Sort(int[] array) {
int t = 0;
if (array.length % 2 == 0)
t = array.length >> 1;
else
t = (array.length >> 1) + 1;
while (t >= 1) {
for (int i = t,temp = 0; i < array.length; i++) {
for (int j = i - t; j >= 0; j =j - t) {
if (array[j] > array[j + t]) {
temp = array[j];
array[j] = array[j + t];
array[j + t] = temp;
}
}
}
if (t == 1)
break;
if (t % 2 == 0)
t = t >> 1;
else
t = (t >> 1) + 1;
}
}
Ich bedanke mich im vorraus !
Gruß
Michi09