Correctheidsbewijs gnomesort
Geplaatst: za 18 jun 2011, 10:36
Kan iemand mij helpen bij het correctheidsbewijs van GnomeSort?
public class GnomeSort {
static void gnomeSort( int[] theArray ) {
for ( int index = 1; index < theArray.length; ) {
if ( theArray[index - 1] <= theArray[index] ) {
++index;
} else {
int tempVal = theArray[index];
theArray[index] = theArray[index - 1];
theArray[index - 1] = tempVal;
--index;
if ( index == 0 ) {
index = 1;
}
}
}
}
}
public class GnomeSort {
static void gnomeSort( int[] theArray ) {
for ( int index = 1; index < theArray.length; ) {
if ( theArray[index - 1] <= theArray[index] ) {
++index;
} else {
int tempVal = theArray[index];
theArray[index] = theArray[index - 1];
theArray[index - 1] = tempVal;
--index;
if ( index == 0 ) {
index = 1;
}
}
}
}
}