3 ms·
Not really bubble-sort-specific; you can make any pair of loops into a single loop that way. for (set up initial conditions for both loops; check the
by lacker 18y ago
Not really bubble-sort-specific; you can make any pair of loops into a single loop that way.
for (set up initial conditions for both loops;
check the outer loop termination condition;
if the inner loop is done reset the inner loop and advance the outer loop,
if the inner loop is not done advance the inner loop) {
// do the inside of the loop
}