예제 #1
0
 private void IniciarAnimacao(Action a)
 {
     if (bgw.IsBusy != true)
     {
         if (radioAsc.Checked)
         {
             Preenchimento.Crescente(vet, 299);
             bgw.RunWorkerAsync(a);
         }
         else if (radioDec.Checked)
         {
             Preenchimento.Decrescente(vet, 299);
             bgw.RunWorkerAsync(a);
         }
         else
         {
             Preenchimento.Aleatorio(vet, 299);
             bgw.RunWorkerAsync(a);
         }
     }
     else
     {
         MessageBox.Show(this,
                         "Aguarde o fim da execução atual...",
                         "Métodos de Ordenação - 2019/2",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
 }
예제 #2
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);
        }
예제 #3
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;
        }
예제 #4
0
 private void iniciaAnimacao(Action a)
 {
     if (bgw.IsBusy != true)
     {
         Preenchimento.Aleatorio(vet, 299);
         bgw.RunWorkerAsync(a);
     }
     else
     {
         MessageBox.Show(this,
                         "Aguarde o fim da execução atual...",
                         "Métodos de Ordenação - 2020/2",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
     }
 }
예제 #5
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;
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
0
        public static int TipoOrdenacao = 1; // Variável resposável pelos tipos de ordenação

        // Metodo resposável por analisar o tipo, preencher o vetor de acordo com tal e retornar o vetor e o nome do tipo de ordenação
        public int[] PreecheVetTipo(int[] vet, out string nomeOrdenacao, int tamanho)
        {
            nomeOrdenacao = "";

            switch (TipoOrdenacao)
            {
            case 1:
                nomeOrdenacao = "Crescente";
                Preenchimento.Crescente(vet, tamanho);
                break;

            case 2:
                nomeOrdenacao = "Decrescente";
                Preenchimento.Decrescente(vet, tamanho);
                break;

            case 3:
                nomeOrdenacao = "Aleatório";
                Preenchimento.Aleatorio(vet, tamanho);
                break;
            }
            return(vet);
        }
예제 #9
0
 private void aleatórioToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     Preenchimento.Aleatorio(vet, 299);
 }
예제 #10
0
 private void decrescenteToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     Preenchimento.Decrescente(vet);
 }
예제 #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);
        }