Bubble sort
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
Urutkan array menjadi urutan naik secara in-place menggunakan bubble sort: jelajahi array membandingkan setiap pasangan tetangga dan tukar jika berada dalam urutan salah. Setelah setiap penuh melewati nilai terbesar yang tersisa telah "melayang" ke akhir, jadi ulangi hingga semuanya terurut.
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. · Selesaikan void bubble_sort(int *a, int n) untuk mengurutkan ⟨n⟩ elemen ke dalam susunan menaik, di tempat. Lalui array secara berulang menukar sebarang pasangan bersebelahan yang tidak teratur.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.