Example #1
0
        public void CombSort()
        {
            var algorithm    = new CombSort();
            var sortedVector = algorithm.Sort(DataDefinition.UnsortedVector());

            Assert.Equal(DataDefinition.SortedVector, sortedVector);
        }
Example #2
0
        public void Test_CombSort()
        {
            int[] arr    = { 170, 45, 75, 90, 802, 24, 2, 66 };
            var   actual = sort.Sort(arr);

            int[] expected = { 2, 24, 45, 66, 75, 90, 170, 802 };

            Assert.Equal(expected, actual);
        }
Example #3
0
        public void OnlyPositiveNumbers_CombSort()
        {
            var combSort = new CombSort();
            var numbers  = new double[] { 5, 9, 3, 9, 10, 9, 2, 4, 13, 10 };
            var expected = new double[] { 2, 3, 4, 5, 9, 9, 9, 10, 10, 13 };

            combSort.Sort(numbers);
            Assert.AreEqual(expected, numbers);
        }
Example #4
0
        public void Characters_CombSort()
        {
            var combSort = new CombSort();
            var word     = "dbca".ToCharArray();
            var expected = "abcd".ToCharArray();

            combSort.Sort(word);
            Assert.AreEqual(expected, word);
        }
Example #5
0
        public void DecimalNumbers_CombSort()
        {
            var combSort = new CombSort();
            var numbers  = new[] { 5.2, 9.3, -3, 9.2, 10.4, 9.6, -2, 4, 13, 10.7 };
            var expected = new[] { -3, -2, 4, 5.2, 9.2, 9.3, 9.6, 10.4, 10.7, 13 };

            combSort.Sort(numbers);
            Assert.AreEqual(expected, numbers);
        }
Example #6
0
        public void PositiveAndNegativeNumbers_CombSort()
        {
            var combSort = new CombSort();
            var numbers  = new double[] { 5, 9, -3, 9, 10, 9, -2, 4, 13, 10 };
            var expected = new double[] { -3, -2, 4, 5, 9, 9, 9, 10, 10, 13 };

            combSort.Sort(numbers);
            Assert.AreEqual(expected, numbers);
        }
Example #7
0
        private static void Sort(Algorithm algorithm, int[] array)
        {
            // Sort
            switch (algorithm)
            {
            case Algorithm.QuickSort:
                QuickSort.Sort(array, 0, array.Length - 1);
                break;

            case Algorithm.QuickSortV2:
                QuickSortV2.Sort(array, 0, array.Length - 1);
                break;

            case Algorithm.BubbleSort:
                BubbleSort.Sort(array);
                break;

            case Algorithm.InsertionSort:
                InsertionSort.Sort(array);
                break;

            case Algorithm.MergeSort:
                MergeSort.Sort(array);
                break;

            case Algorithm.SelectionSort:
                SelectionSort.Sort(array);
                break;

            case Algorithm.ShellSort:
                ShellSort.Sort(array);
                break;

            case Algorithm.HeapSort:
                HeapSort.Sort(array);
                break;

            case Algorithm.CombSort:
                CombSort.Sort(array);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #8
0
 public void CombSort() => combSort.Sort(Copy(data));