data-structures · intermediate · ~15 min
A simple O(n²) sort; understand its invariants.
Implement void bubble_sort(int *a, size_t n) sorting a ascending in place. Tested on arrays of various sizes including empty.
#include <stddef.h>
void bubble_sort(int *a, size_t n) {
/* TODO */
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.