Improving bubblesort to run faster?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Does anyone know how to make this run faster?
tic
a = [8783216623,1376710497,9690826665,1570640605,7500570041,2833455215,5428161051,9156540724,520448916,5918542685,9323641738,3120571877,1466686979,372712728,10508227,614468445,8934640773,784334388,213084816631,62069482,6699641272,1309686517,6512222692,1877042633]
b = length(a);
count_s = 0;
count_o = 0;
for i = 1:b
for n = 1:b-1
count_o = count_o +1;
if a(n) >= a(n+1)
temp = a(n);
a(n) = a(n+1);
a(n+1) = temp;
count_s = count_s + 1;
end
if count_s == 0;
display('fully sorted')
end
end
end
toc
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre Pulsed Waveforms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!