Exemplo n.º 1
0
        public void sortTimes(int times)
        {
            Stopwatch      stopw            = new Stopwatch();
            ArrayGenerator myArrayGenerator = new ArrayGenerator();

            totalEquations = 0;
            stopw.Restart();
            for (int i = 0; i < times; i++)
            {
                int[] randomOrder = myArrayGenerator.generateArrayRandom(20);
                startSort(randomOrder, 0, randomOrder.Length - 1);
            }

            double averageTimes = (float)totalEquations / times;

            Console.WriteLine("Finished average equations: " + averageTimes);
            Console.WriteLine("Swaps: " + (float)swaps / times);

            Console.Out.WriteLine("Time " + (float)stopw.ElapsedMilliseconds / times);
        }
Exemplo n.º 2
0
        public void sortTimes(int times)
        {
            Console.WriteLine("QUICKSORT");
            Stopwatch stopw = new Stopwatch();
            ArrayGenerator myArrayGenerator = new ArrayGenerator();
            totalEquations = 0;
            stopw.Restart();
            for (int i = 0; i < times; i++)
            {
                int[] randomOrder = myArrayGenerator.generateArray(10000);
                startSort(randomOrder, 0, randomOrder.Length -1);

            }

            double averageTimes = (float)totalEquations / times;
            Console.WriteLine("Finished average equations: " + averageTimes);
            Console.WriteLine("Swaps: " + (float)swaps/times);

            Console.Out.WriteLine("Time " + (float)stopw.ElapsedMilliseconds/times);
        }