如下的内容段是关于C#折半插入排序算法演示的内容。
public static void BinarySort (int[] list)
{
for (int i = 1; i < list.Length; i+ +)
{
int low = 0;
int high = i - 1;
int Temp = list [i];
while (low <= high)
{
int mid = (low + high) / 2;
IF (Temp < list [mid])
high = mid - 1;
else
low = mid + 1;
}
for (int j = i - 1; j > = low; j-)
list [j + 1] = list [j];
list [low] = Temp;
}
}
网友评论