Data-Structures/Sorting_Algorithms/Sorting_Algorithms/Program.cs
/// <summary>
/// Insertion Sort method sorts a given array of integers
/// </summary>
/// <param name="inputArray"></param>
Insertion Sort method sorts a given array of integers
Insertion Sort method sorts a given array of integers
static void InsertionSort(int[] inputArray)
        {
            for (int i = 1; i < inputArray.Length; i++)
            {
                int temp = inputArray[i];
                int j = i - 1;
                while (j >= 0 && temp < inputArray[j])
                {
                    inputArray[j + 1] = inputArray[j];
                    j--;
                }
                inputArray[j + 1] = temp;
            }
        }
static void InsertionSort ( int [ ] inputArray ) { for ( int i = 1 ; i < inputArray . Length ; i ++ ) { int temp = inputArray [ i ] ; int j = i - 1 ; while ( j >= 0 && temp < inputArray [ j ] ) { inputArray [ j + 1 ] = inputArray [ j ] ; j -- ; } inputArray [ j + 1 ] = temp ; } }
Insertion Sort method sorts a given array of integers
Insertion Sort method sorts a given array of integers
inputArray
int[]
None