Skip to content

Instantly share code, notes, and snippets.

@AbhinavPradeep
Created June 24, 2020 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhinavPradeep/d90e38de177c4f7e12ad4b2e0125982d to your computer and use it in GitHub Desktop.
Save AbhinavPradeep/d90e38de177c4f7e12ad4b2e0125982d to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
namespace SortingArrays
{
class InsertionSort
{
public void Sort(int[] input)
{
var watch = Stopwatch.StartNew();
try
{
for (int i = 0; i < input.Length - 1; i++)
{
for (int j = i + 1; j < 0; j--)
{
if (input[j] > input[j - 1])
{
int Temp = input[j];
input[j] = input[j - 1];
input[j - 1] = Temp;
}
}
}
watch.Stop();
}
finally
{
PrintArray printArray = new PrintArray();
printArray.PrintIntegerArray(input);
Console.WriteLine($" Insertion Sort executed in {watch.ElapsedTicks} ticks");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment