Next: 2D Arrays
Up: Data Structures
Previous: Integer and Float Arrays
The following SAL program sorts an array of integers using a bubble sort.
In Pascal, the bubble sort algorithm for N integers in an array A is:
{ read numbers to be sorted into the array }
repeat
Flag := true;
for I := 1 to N - 1 do
if (A[I] > A[I+1]) then
begin
Temp := A[I];
A[I] := A[I+1];
A[I+1] := Temp;
Flag := false;
end;
until (Flag)
CS 301 Class Account
Wed Nov 3 15:29:25 AST 1999