Exemplo n.º 1
0
 //Metodo de Ordenamiento de HeapSort
 public void HeapSort()
 {
     HeapSorter miHeap = new HeapSorter(ref Arreglo_numeros, rdbtnAscendente.Checked);
     miHeap.sortArray();
 }
Exemplo n.º 2
0
        private void btnOrdenar_Click(object sender, EventArgs e)
        {
            Stopwatch miReloj = new Stopwatch();
            miReloj.Restart();
            this.Cursor = Cursors.WaitCursor;
            btnOrdenar.Enabled = false;
            btnAgregar.Enabled = false;
            cmbMetodos.Enabled = false;

            if (cmbMetodos.SelectedIndex != -1)
            {
                if (cmbMetodos.SelectedItem.ToString() == "QuickSort")
                    QuickSort(ref Arreglo_numeros, 1, Arreglo_numeros.Length - 1, ref Arreglo);
                else if (cmbMetodos.SelectedItem.ToString() == "MergeSort")
                {
                    MergeSort(ref Arreglo_numeros, 1, Arreglo_numeros.Length - 1, ref Arreglo);
                }
                else if (cmbMetodos.SelectedItem.ToString() == "HeapSort")
                {
                    HeapSorter hs = new HeapSorter(ref Arreglo_numeros);
                    hs.ascendente = rdbtnAscendente.Checked;
                    hs.sortArray(ref Arreglo, ref Arreglo_heap);
                }
            }
            else
                MessageBox.Show("Seleccione un metodo de ordenamiento");
            this.Cursor = Cursors.Default;
            btnOrdenar.Enabled = true;
            btnAgregar.Enabled = true;
            cmbMetodos.Enabled = true;
            miReloj.Stop();
            lblTiempo.Text = "Tiempo de ejecucion: " + miReloj.Elapsed.TotalSeconds.ToString().Substring(0, 4) + "s";
            lblTiempo.Visible = true;
        }