Sorting
TimeO(n²)SpaceO(1)
Repeatedly compare adjacent elements and swap them when they're out of order. After each pass the largest remaining value bubbles to its final position.
Key idea. Adjacent-swap sorting. Simple to reason about, but every pass only fixes one element — quadratic work makes it impractical beyond tiny inputs.
1
Loading…
—