public void Test1() { var list = new List <int> { 5, 8, 4, 1, 2, 6, 4, 7, 9, 2 }; MergeSorter.MergeSort <int>(list, Comparer <int> .Default); }
public void ShouldSortMultipleItems() { var sorter = new MergeSorter <int>(); int[] items = { 8, 3, 4, 12, 73, 1, 3, 4, 5 }; sorter.MergeSort(items); Assert.AreEqual(new int[] { 1, 3, 3, 4, 4, 5, 8, 12, 73 }, items); }
public void ShouldSortEmptyArray() { var sorter = new MergeSorter <int>(); int[] items = { }; sorter.MergeSort(items); Assert.IsEmpty(items); }
public void ShouldSortTwoItems() { var sorter = new MergeSorter <int>(); int[] items = { 8, 3 }; sorter.MergeSort(items); Assert.AreEqual(new int[] { 3, 8 }, items); }
public void TestMergeSort() { var arr = new int[] { 7, 2, 8, 3, 5, 1 }; var sorter = new MergeSorter(); Console.WriteLine(arr.Print()); sorter.MergeSort(ref arr); Console.WriteLine(arr.Print()); }
public void TestMergeSort_WhenArrLengthIs_3() { var arr = new int[] { 2, 7, 1 }; var sorter = new MergeSorter(); Console.WriteLine(arr.Print()); sorter.MergeSort(ref arr); Console.WriteLine(arr.Print()); }
public void CanPerformMergeSort() { var array = new int[] { 2, 5, -4, 11, 0, 18, 22, 67, 51, 6 }; var arrayToSort = new int[] { 2, 5, -4, 11, 0, 18, 22, 67, 51, 6 }; var sorter = new MergeSorter(); sorter.MergeSort(arrayToSort); Assert.AreEqual(array.Length, arrayToSort.Length); var previousItem = array.Min() - 1; foreach (var item in arrayToSort) { Assert.IsTrue(array.Contains(item)); Assert.IsTrue(previousItem < item); previousItem = item; } }
public void Generate(int listSize) { // Generate Random List ResetStopWatch(); var randomList = CreateRandomNumberList(listSize); stopWatch.Stop(); UI.PrintTimer($"Integer List Generated (Size: {randomList.Length})", stopWatch.Elapsed); // Bubble Sort ResetStopWatch(); BubbleSorter.BubbleSort(randomList); stopWatch.Stop(); UI.PrintTimer($"List Sorted With Bubble Sort", stopWatch.Elapsed); // Merge Sort ResetStopWatch(); MergeSorter.MergeSort(randomList); stopWatch.Stop(); UI.PrintTimer($"List Sorted With Merge Sort", stopWatch.Elapsed); }
public int[] Merge_Sort_Test(int[] array) { MergeSorter.MergeSort(array); return(array); }
public void SortByMerge() { mergeSortResult = mergeSorter.MergeSort(mergeTestArray, 0, mergeTestArray.Length - 1); resultDisplay.text = mergeSortResult.ToString(); }
public void MergeSorter_Duplicates_Test() { int[] unsortedInts = { 6, 12, 8, 2, 9, 6 }; MergeSorter.MergeSort(unsortedInts); }
public void MergeSorter_Check_Sorting_Behavior() { int[] unsortedInts = { 6, 12, 8, 2, 9 }; MergeSorter.MergeSort(unsortedInts); }
static void Main(string[] args) { MergeSorter oSorter = new MergeSorter(); //-------------------------------------- //Create Array List, add some numbers //-------------------------------------- ArrayList arrayUnsorted = new ArrayList(); arrayUnsorted.Add(1); arrayUnsorted.Add(33); arrayUnsorted.Add(4); arrayUnsorted.Add(43); //-------------------------------------- //Sort //-------------------------------------- ArrayList arraySorted = oSorter.MergeSort(arrayUnsorted); //-------------------------------------- //Print //-------------------------------------- foreach (int i in arraySorted) { Console.WriteLine(i); } }
public void MergeSort(IEnumerable <int> list) { var result = MergeSorter.MergeSort(list.ToList()); }