Bubble sort · Ordenação por bolha
Bubble sort
Sort an array into ascending order in place using bubble sort: walk through the array comparing each pair of neighbours and swapping them if they're in the wrong order. After each full pass the largest remaining value has "bubbled" to the end, so repeat until everything is sorted.
Bubble sort
Ordena um array em ordem crescente in loco usando bubble sort: percorra o array comparando cada par de vizinhos e trocando-os se estiverem na ordem errada. Após cada passagem completa, o maior valor restante "subiu" para o final, então repita até que tudo esteja ordenado.
Complete void bubble_sort(int *a, int n) to sort the n elements into ascending order, in place. Repeatedly pass through the array swapping any out-of-order neighbours. · Complete void bubble_sort(int *a, int n) para classificar os elementos n em ordem crescente, in-place. Passe repetidamente pelo array trocando quaisquer vizinhos fora de ordem.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.