Пример #1
0
        static void Main(string[] args)
        {
            // TODO Delete
            //// FOR TEST
            var t = QuickSort.Sort(devTestArray);

            Environment.Exit(1);
            //// FOR TEST

            var       testArray = GenereateArray(ArrayLength);
            Stopwatch watch;

            // InsertionSort
            watch = System.Diagnostics.Stopwatch.StartNew();
            var insertionOutput = InsertionSort.Sort(testArray);

            watch.Stop();
            var insertionDuration = watch.ElapsedMilliseconds;

            // MergeSort
            watch = System.Diagnostics.Stopwatch.StartNew();
            var mergeOutput = MergeSort.Sort(testArray);

            watch.Stop();
            var mergeDuration = watch.ElapsedMilliseconds;


            // SelectionSort
            watch = System.Diagnostics.Stopwatch.StartNew();
            var selectionOutput = SelectionSort.Sort(testArray);

            watch.Stop();
            var selectionDuration = watch.ElapsedMilliseconds;

            // BubbleSort
            watch = System.Diagnostics.Stopwatch.StartNew();
            var bubbleOutput = BubbleSort.Sort(testArray);

            watch.Stop();
            var bubbleDuration = watch.ElapsedMilliseconds;

            // Results
            Console.WriteLine("Array length: " + ArrayLength + " items");
            Console.WriteLine();
            Console.WriteLine("Insertion Sort Duration: " + insertionDuration + " ms");
            Console.WriteLine("Merge Sort Duration: " + mergeDuration + " ms");
            Console.WriteLine("Selection Sort Duration: " + selectionDuration + " ms");
            Console.WriteLine("Bubble Sort Duration: " + bubbleDuration + " ms");

            Console.ReadLine();
        }
Пример #2
0
        public void Insertion()
        {
            var k = make_random_array();

            Assert.IsTrue(InsertionSort.Sort(k.Item2).SequenceEqual(k.Item1));
        }