C# · 12月 28, 2021

C#折半插入排序算法实现方法

本文实例讲述了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]; //Find while (low <= high) { int mid = (low + high) / 2; IF (Temp < list [mid]) high = mid – 1; else low = mid + 1; } //backward shift for (int j = i – 1; j > = low; j-) list [j + 1] = list [j]; list [low] = Temp; }}

希望本文所述对大家的C#程序设计有所帮助。