function y = bubble( x )n = length(x); %This is where the error occurs
sort= 0;k = 0;while ~ sort sort =1; k = k+1; for j = 1:n-k if x(j)>x(j+1) temp = x(j); x(j)=x(j+1); x(j+1) = temp; sorted = 0; end endendp=x
Best Answer