Beispiel #1
0
        public static double countBasics(int size, int iterations)
        {
            int randUpper = (int)Math.Floor(size / 2.0);

            return((from number in Enumerable.Range(0, iterations)
                    select(double) Median.BruteForceMedianCount(randomArray(size, -randUpper, randUpper)) / iterations
                    ).Sum()); // Could use .Average() but careful for int.MaxSize
        }
Beispiel #2
0
        public static double countTime(int size, int iterations)
        {
            Stopwatch stopWatch = new Stopwatch();
            int       randUpper = (int)Math.Floor(size / 2.0);
            double    output;

            double[] A;
            for (int i = 0; i < iterations; i++)
            {
                A = randomArray(size, -randUpper, randUpper);

                // Time over algorithm
                stopWatch.Start();
                output = Median.BruteForceMedian(A);
                stopWatch.Stop();
            }
            return(stopWatch.ElapsedTicks / (10 * iterations));
        }