Monday, November 16, 2009

c# insert sort algorithm implementation

        private void insert_sort( int[] s )
{
for( int k = 1; k < s.Length ; k++ )
{
int value = s[k];
for( int i = 0; i <= k - 1; i++ )
{
if( value < s[i] )
{
for( int j = k - 1; j >= i; j-- )
s[j + 1] = s[j];
s[i] = value;
break;
}
}
}
}

No comments: