Sunday, January 13, 2008

Insertion Sort

a=floor(100*rand(1,10));
%figure(1)
%bar(a)
%axis tight
%set(gca,'nextplot','replacechildren');
%p = 1;
for i=2:length(a)
for j=1:i-1
if a(i) temp = a(i);
for k=i:-1:j+1
a(k)=a(k-1);
end
a(j)=temp;
end
%bar(a)
%pause(.1)
%F(p) = getframe;
%p = p+1;
end
a
end


%close all
%pause
%movie(F,1)
a =

49 89 82 64 81 66 34 28 34 53


a =

49 82 89 64 81 66 34 28 34 53


a =

49 64 82 89 81 66 34 28 34 53


a =

49 64 81 82 89 66 34 28 34 53


a =

49 64 66 81 82 89 34 28 34 53


a =

34 49 64 66 81 82 89 28 34 53


a =

28 34 49 64 66 81 82 89 34 53


a =

28 34 34 49 64 66 81 82 89 53


a =

28 34 34 49 53 64 66 81 82 89