C# Implementation
suggest changepublic static class ShellSort
{
public static void Sort(int[] values)
{
for (int gap = values.Length / 2; gap > 0; gap /= 2)
{
for (int index = gap; index < values.Length; index++)
{
int item = values[index];
int destination = index;
while (destination >= gap && values[destination - gap] > item)
{
values[destination] = values[destination - gap];
destination -= gap;
}
values[destination] = item;
}
}
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents