Exemple #1
0
        static void Main(string[] args)
        {
            int[] arr = new int[] { 13, 45, 5, 7, 2, 1234, 23, -2, 34, 0 };

            ShellSort.Sort(arr);

            Console.WriteLine(string.Join(' ', arr));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            int[] arr = { 1, 5, 2, 10 };

            ShellSort ob = new ShellSort();

            ob.Sort(arr);
            ob.PrintArray(arr);

            Console.WriteLine("Hello World!");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            int[] array = { 3, 7, 4, 4, 6, 5, 8, 12, 19, 2, 0 };

            ShellSort.sort(array);

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]);
            }
        }
Exemple #4
0
        public static void Main()
        {
            int [] arr = { 30, 16, 5, 9, 2, 12, 4, 10 };
            Console.Write("Unsorted Array:\n");
            printArray(arr);
            ShellSort ob = new ShellSort();

            ob.sort(arr);
            Console.Write("\nSorted Array:\n");
            printArray(arr);
        }
Exemple #5
0
        public void Test1()
        {
            // Arrange
            var data     = new int[] { 35, 33, 42, 10, 14, 19, 27, 44 };
            var expected = new List <int> {
                10, 14, 19, 27, 33, 35, 42, 44
            };
            // Act
            var shellSort = new ShellSort();

            // Assert
            Assert.True(expected.SequenceEqual(shellSort.Sort(data)));
        }
Exemple #6
0
        public static void Main(string[] args)
        {
            const int count = 100000;
            var       array = Enumerable.Range(1, count).Shuffle().ToArray();

            var sw = new Stopwatch();

            sw.Start();
            ShellSort.Start(array);
            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds + "ms");
            // 4ms for 100000

            Console.WriteLine(array.IsAscSort());
        }
Exemple #7
0
        public static void Main()

        {
            int [] arr = { 30, 16, 5, 9, 2, 12, 4, 10 };

            Console.Write("Array before sorting:\n");

            printArray(arr);

            ShellSort ob = new ShellSort();

            ob.sort(arr);

            Console.Write("\nArray after sorting:\n");

            printArray(arr);
        }