public IActionResult OrdenacaoPorFundicao([FromBody] IList <string> lista) { var stopwatch = new Stopwatch(); stopwatch.Start(); Auxiliares.Ordena(lista, 0, lista.Count - 1); stopwatch.Stop(); return(Ok(new { stopwatch.Elapsed, lista })); }
public IActionResult OrdenacaoPorInsercao([FromBody] IList <string> lista) { var stopwatch = new Stopwatch(); stopwatch.Start(); for (int atual = 0; atual < lista.Count; atual++) { int analise = atual; int menor = Auxiliares.bucaMenor(lista, analise); Auxiliares.trocar(lista, atual, menor); } stopwatch.Stop(); return(Ok(new { stopwatch.Elapsed, lista })); }
public static int bucaMenor(IList <string> lista, int comeco) { int menor = comeco; for (var atual = comeco; comeco < lista.Count; atual++) { if (lista.Count <= atual) { return(menor); } if (Auxiliares.EMenorQue(lista[menor], lista[atual])) { menor = atual; } } return(menor); }
public IActionResult OrdenacaoPorSelecao([FromBody] IList <string> lista) { var stopwatch = new Stopwatch(); stopwatch.Start(); for (int atual = 1; atual < lista.Count; atual++) { int analise = atual; while (analise > 0 && Auxiliares.EMenorQue(lista[analise - 1], lista[analise])) { Auxiliares.trocar(lista, analise - 1, analise); analise--; } } stopwatch.Stop(); return(Ok(new { stopwatch.Elapsed, lista })); }