Created
June 24, 2020 06:38
-
-
Save AbhinavPradeep/d90e38de177c4f7e12ad4b2e0125982d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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