EXCHANGE SORT


 


 

The Algorithm Pseudocode:

for i := 2 to list_size do
begin
for j := list_size downto i do
if a[j - 1] > a [j] then
begin
temp := a[j - 1];
a[j] := temp
end
end;


 

The Exchange Sort Algorithm:

 

1. Compare the first pair of numbers (positions 0 and 1) and reverse them if they are not in the correct order.

 

2. Repeat for the next pair (positions 1 and 2).

 

3. Continue the process until all pairs have been checked.

 

4. Repeat steps 1 through 3 for positions 0 through n - 1 to i (for i = 1, 2, 3, ...) until no pairs remain to be checked.

 

5. The list is now sorted.