Beispiel #1
0
        static void Main(string[] args)
        {
            List <int> inputFiles = DataGeneratorUtils.FetchData(-20000, 20000, 100000);

            _finder = new PairFinder(inputFiles);

            Random          r     = new Random();
            List <TimeSpan> stats = new List <TimeSpan>();

            for (int i = 0; i < 1000; i++)
            {
                stats.Add(ComputeSum(r.Next(-20000, 20000)));
            }

            Console.WriteLine($"Total Time: {stats.Sum(a => a.Milliseconds)}ms ({stats.Sum(a => a.Ticks)} ticks)");
            Console.WriteLine($"Average Time: {stats.Average(a => a.Milliseconds)}ms ({stats.Average(a => a.Ticks)} ticks)");

            Console.Read();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            List <int> inputData  = DataGeneratorUtils.FetchData(-10, 10, 10);
            List <int> sortedData = new List <int>(inputData);

            sortedData.Sort();

            SelfBalancingTree tree = new SelfBalancingTree();

            Console.WriteLine(string.Join(",", inputData));
            Console.WriteLine(string.Join(",", sortedData));

            for (var i = 0; i < inputData.Count; i++)
            {
                tree.AddValue(inputData[i]);
                Console.WriteLine(tree.GetMedian());
            }

            Console.WriteLine("Done");
            Console.Read();
        }