Ordenação
Veja os algoritmos de ordenação em execução passo a passo: compare, troque e posicione os elementos até o array ficar ordenado.
Insertion SortWatch insertion sort build a sorted section one element at a time.Selection SortSee selection sort repeatedly pick the smallest element and place it.Merge SortWatch merge sort divide the array and merge the pieces back in order.Bubble SortSee adjacent elements compared and swapped until the array is sorted.Quick SortWatch quick sort partition around a pivot and recurse on each side.Heap SortSee heap sort build a max-heap and extract the largest element each time.Radix SortWatch radix sort order numbers digit by digit, from least significant.Counting SortSee counting sort tally values and rebuild the array in sorted order.
Comparação de Ordenação
| Algoritmo | Melhor | Médio | Pior | Espaço | Estável |
|---|---|---|---|---|---|
| Insertion Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Selection Sort | O(n²) | O(n²) | O(n²) | O(1) | No |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
| Bubble Sort | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) | No |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | No |
| Radix Sort | O(nk) | O(nk) | O(nk) | O(n + k) | Yes |
| Counting Sort | O(n + k) | O(n + k) | O(n + k) | O(n + k) | Yes |