For i=2 to N
aux=x(i)
k=i-1
sw=«falso»
Do while (sw=«falso») and (k>=1)
If aux<x(k)
x(k+1)=x(k)
k=k-1
Else
sw=«verdadero»
Endif
Endwhile
x(k+1)=aux
Endfor
aux=x(i)
k=i-1
sw=«falso»
Do while (sw=«falso») and (k>=1)
If aux<x(k)
x(k+1)=x(k)
k=k-1
Else
sw=«verdadero»
Endif
Endwhile
x(k+1)=aux
Endfor
0 comentarios