Esempio n. 1
0
        private void mergeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int[] vetor = new int[tamVet]; // TODO (tamanho deverá ser escolhido pelo usuário)
            switch (codOrdenacao)
            {
            case 0:
                Preenchimento.Crescente(vetor);
                break;

            case 1:
                Preenchimento.Decrescente(vetor);
                break;

            case 2:
                Preenchimento.Aleatorio(vetor, tamVet);
                break;
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            OrdenacaoEstatistica.mergeSort(vetor, 0, vetor.Length - 1);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: " + tamVet +
                            "\nOrdenação inicial: " + nomeOrdenacao +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + OrdenacaoEstatistica.cont_c +
                            "\nNº de trocas: " + OrdenacaoEstatistica.cont_t,
                            "Estatísticas do Método MergeSort",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Esempio n. 2
0
        private void mergesortToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string preenchimento = "";

            vet = new int[Convert.ToInt32(comboBox1.SelectedValue)];
            Preenchimento.Aleatorio(vet, vet.Length);

            var stopwatch = new Stopwatch();

            stopwatch.Start(); // inicia cronômetro

            int i, j;

            i = 0;
            j = vet.Length - 1;
            IniciarAnimacao(() => OrdenacaoEstatistica.MergeSort(vet, i, j));

            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: " + vet.Length +
                            "\nOrdenação inicial: " + preenchimento +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + OrdenacaoEstatistica.contTest +
                            "\nNº de trocas: " + OrdenacaoEstatistica.contTrocas,
                            "Estatísticas do Método MergeSort",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            OrdenacaoEstatistica.contTest   = 0;
            OrdenacaoEstatistica.contTrocas = 0;
        }
Esempio n. 3
0
        private void mergesortToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            int tamanhoVet = DefineTamanho();

            int[]  vetor         = new int[tamanhoVet];
            string nomeOrdenacao = "";

            vetor = PreecheVetTipo(vetor, out nomeOrdenacao, tamanhoVet);

            OrdenacaoEstatistica.cont_c = 0;
            OrdenacaoEstatistica.cont_t = 0;

            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            OrdenacaoEstatistica.MergeSort(vetor, 0, vetor.Length - 1);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            $"Tamanho do vetor: {tamanhoVet}" +
                            $"\nOrdenação inicial: {nomeOrdenacao}" +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            $"\nNº de comparações: {OrdenacaoEstatistica.cont_c}" +
                            $"\nNº de trocas: {OrdenacaoEstatistica.cont_t}",
                            "Estatísticas do Método MergeSort",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Esempio n. 4
0
        //METODOS ESTATISTICOS
        #region Bolha
        private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            string preenchimento = "";

            vet = new int[Convert.ToInt32(comboBox1.SelectedValue)];

            if (radioAsc.Checked)
            {
                Preenchimento.Crescente(vet, tamanho);
                preenchimento = "Crescente";
            }
            else if (radioDec.Checked)
            {
                Preenchimento.Decrescente(vet, tamanho);
                preenchimento = "Decrescente";
            }
            else if (radioAleatorio.Checked)
            {
                Preenchimento.Aleatorio(vet, tamanho);
                preenchimento = "Aleatório";
            }


            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            OrdenacaoEstatistica.BubbleSort(vet);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido


            MessageBox.Show(this,
                            "Tamanho do vetor: " + vet.Length +
                            "\nOrdenação Inicial: " + preenchimento +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + OrdenacaoEstatistica.contTest +
                            "\nNº de trocas: " + OrdenacaoEstatistica.contTrocas,
                            "Estatísticas do Método Bolha",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

            OrdenacaoEstatistica.contTest   = 0; //ao final do método eu zero os contadores
            OrdenacaoEstatistica.contTrocas = 0;
        }
Esempio n. 5
0
        private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            int tamanhovet = Convert.ToInt32(comboBox1.Text);

            int[]  vetor       = new int[tamanhovet]; // TODO (tamanho deverá ser escolhido pelo usuário)
            string auxPreenchi = "";

            int[] vetReturn = new int[2];


            if (rdbCresc.Checked == true)
            {
                Preenchimento.Crescente(vetor);
                auxPreenchi = "Crescente";
            }
            else if (rdbDesc.Checked == true)
            {
                Preenchimento.Decrescente(vetor);
                auxPreenchi = "Decrescente";
            }
            else
            {
                Preenchimento.Aleatorio(vetor, 1000);
                auxPreenchi = "Aleatório";
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            vetReturn = OrdenacaoEstatistica.Bolha(vetor);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: " + tamanhovet +
                            "\nOrdenação inicial: " + auxPreenchi +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + vetReturn[0] +
                            "\nNº de trocas: " + vetReturn[1],
                            "Estatísticas do Método Bolha",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Esempio n. 6
0
        private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            int[] vetor = new int[1000];          // TODO (tamanho deverá ser escolhido pelo usuário)
            Preenchimento.Aleatorio(vetor, 1000); // TODO (preenchimento inicial deverá ser escolhido pelo usuário)
            var stopwatch = new Stopwatch();

            stopwatch.Start();                                 // inicia cronômetro
            OrdenacaoEstatistica.Bolha(vetor);
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: TODO" +
                            "\nOrdenação inicial: TODO" +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: TODO" +
                            "\nNº de trocas: TODO",
                            "Estatísticas do Método Bolha",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Esempio n. 7
0
        private void shellSortToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrdenacaoEstatistica estatiticas = new OrdenacaoEstatistica();

            IniciaEstatisticas(estatiticas, 6); // ShellSort
        }
Esempio n. 8
0
        private void quickSortToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrdenacaoEstatistica estatiticas = new OrdenacaoEstatistica();

            IniciaEstatisticas(estatiticas, 3); // Quicksort
        }
Esempio n. 9
0
        private void selecaoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrdenacaoEstatistica estatiticas = new OrdenacaoEstatistica();

            IniciaEstatisticas(estatiticas, 2); // Seleção
        }
Esempio n. 10
0
        private void inserçãoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OrdenacaoEstatistica estatiticas = new OrdenacaoEstatistica();

            IniciaEstatisticas(estatiticas, 1); // Inserção
        }
Esempio n. 11
0
        private void IniciaEstatisticas(OrdenacaoEstatistica estatistica, int NumeroMetodo)
        {
            int    TA;
            String NomeMetodo = "Inicial";

            if (!Int32.TryParse(tamanhoArray.Text, out TA))
            {
                TA = 1000;
                tamanhoArray.Text = "1000";
            }

            int[] vetor = new int[TA];

            if (TipoOrdenacao.Text == "Aletorio")
            {
                Preenchimento.Aleatorio(vetor, 300);
            }
            else if (TipoOrdenacao.Text == "Decrecente")
            {
                Preenchimento.Decrescente(vetor, 300);
            }
            else
            {
                Preenchimento.Crescente(vetor, 300); TipoOrdenacao.Text = "Crecente";
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();      // inicia cronômetro
            estatistica.cont_c = 0; //zera os contadores do metodo ordenaçãoestatistica
            estatistica.cont_t = 0;
            switch (NumeroMetodo)
            {
            case 0:     //Bolha
                estatistica.Bolha(vetor);
                NomeMetodo = "Bolha";
                break;

            case 1:     //Inserção
                estatistica.Insercao(vetor);
                NomeMetodo = "Inserção";
                break;

            case 2:     //Selecão
                estatistica.selecao(vetor);
                NomeMetodo = "Selecao";
                break;

            case 3:     //QuickSort
                estatistica.quickSort(vetor, 0, vetor.Length - 1);
                NomeMetodo = "QuickSort";
                break;

            case 4:     //HeapSort
                estatistica.heapSort(vetor);
                NomeMetodo = "HeapSort";
                break;

            case 5:     //MergeSort
                estatistica.mergeSort(vetor, 0, vetor.Length - 1);
                NomeMetodo = "MergeSort";
                break;

            case 6:     //ShellSort
                estatistica.shellSort(vetor);
                NomeMetodo = "ShellSort";
                break;

            default:     //QuickSort
                estatistica.quickSort(vetor, 0, vetor.Length - 1);
                NomeMetodo = "QuickSort";
                break;
            }
            stopwatch.Stop();                                  // interrompe cronômetro
            long elapsed_time = stopwatch.ElapsedMilliseconds; // calcula o tempo decorrido

            MessageBox.Show(this,
                            "Tamanho do vetor: " + vetor.Length +
                            "\nOrdenação inicial: " + TipoOrdenacao.Text +
                            "\n\nTempo de execução: " + String.Format("{0:F4} seg", elapsed_time / 1000.0) +
                            "\nNº de comparações: " + estatistica.cont_c +
                            "\nNº de trocas: " + estatistica.cont_t,
                            "Estatísticas do Método " + NomeMetodo,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
        }
Esempio n. 12
0
        private void bolhaToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            OrdenacaoEstatistica estatiticas = new OrdenacaoEstatistica();

            IniciaEstatisticas(estatiticas, 0); // Bolha
        }