|
Universidad de Costa Rica
|
|
|
|
BubbleSort()
procedure swap ( var x, y: recordtype )
{ swap exchanges the values of x and y }
var
temp: recordtype;
begin
temp := x;
x := y;
y := temp
end; { swap }
(1) for i := 1 to n-1 do
(2) for j := n downto i+1 do
(3) if A[j].key < A[j-1].key then
(4) swap(A[j], A[j-1])
|