SoFunction
Updated on 2025-03-06

Implementation method of C# fold half insert sorting algorithm

This article describes the implementation method of C# fold half insertion sorting algorithm. Share it for your reference. The specific implementation method is as follows:

public static void BinarySort (int[] list)
{
  for (int i = 1; i < ; 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;
  }
}

I hope this article will be helpful to everyone's C# programming.