Exemplo n.º 1
0
        public static void RunRandomAlgorithm()
        {
            System.Console.WriteLine("Iniciando Rotina Aleatória");
            SelectionSort selectionSort   = new SelectionSort();
            BubbleSort    bubbleSort      = new BubbleSort();
            QuickSort     quickSort       = new QuickSort();
            Random        rng             = new Random();
            int           randomAlgorithm = rng.Next(1, 3);

            switch (randomAlgorithm)
            {
            case 1:
                selectionSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
                break;

            case 2:
                bubbleSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
                break;

            case 3:
                bubbleSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
                break;

            default:
                System.Console.WriteLine("Algoritmo ainda não implementado");
                break;
            }
        }
Exemplo n.º 2
0
        public static void RunConsecutiveTests()
        {
            System.Console.WriteLine("Iniciando rotina de testes consecutivos. Isso deve levar um tempo.");
            SelectionSort selectionSort = new SelectionSort();
            BubbleSort    bubbleSort    = new BubbleSort();
            QuickSort     quickSort     = new QuickSort();
            MergeSort     mergeSort     = new MergeSort();

            for (int j = 0; j < 8; j++)
            {
                int quantity = 10;
                for (int i = 0; i < 6; i++)
                {
                    double[] numbers  = NumberGeneratorService.GenerateNumbers(quantity);
                    double[] numbers1 = NumberGeneratorService.GenerateNumbers(quantity);
                    double[] numbers2 = NumberGeneratorService.GenerateNumbers(quantity);
                    double[] numbers3 = NumberGeneratorService.GenerateNumbers(quantity);
                    selectionSort.SortAndStore(numbers);
                    bubbleSort.SortAndStore(numbers1);
                    quickSort.SortAndStore(numbers2);
                    mergeSort.SortAndStore(numbers3);
                    quantity = quantity * 10;
                }
            }
        }
Exemplo n.º 3
0
        public static void RunHugeTests()
        {
            System.Console.WriteLine("Iniciando rotina de testes grande");
            SelectionSort selectionSort = new SelectionSort();
            BubbleSort    bubbleSort    = new BubbleSort();
            QuickSort     quickSort     = new QuickSort();
            MergeSort     mergeSort     = new MergeSort();

            double[] numbers1 = selectionSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
            System.Console.WriteLine("Organizado: " + selectionSort.SortTest(numbers1));
            double[] numbers2 = bubbleSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
            System.Console.WriteLine("Organizado: " + bubbleSort.SortTest(numbers2));
            double[] numbers3 = quickSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
            System.Console.WriteLine("Organizado: " + quickSort.SortTest(numbers3));
            double[] numbers4 = mergeSort.SortAndWrite(NumberGeneratorService.GenerateNumbers());
            System.Console.WriteLine("Oganizado: " + mergeSort.SortTest(numbers4));
        }