SORTING BY EXCHANGE
By
Dept. of CSE
PVPSIT, Kanuru.
PRASAD V. POTLURI SIDDHARTHA INSTITUTE OF TECHNOLOGY
Dept of CSE
2025 - 26
SORTING BY EXCHANGE
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
begin
sorted:=false;
i:=0;
while (i<n) and (not sorted) do
begin
sorted:=true;
i:=i+1
for j:=1 to n-i do
if a[j]>a[j+1] then
begin
t:=a[j];
a[j]:= a[j+1];
a[j+1]:=t;
sorted:= false
end
end
end
Dept of CSE
2025 - 26
Pseudo-code
begin
for i:=1 to n-1 do
for j:=1 to n-i do
if a[j] > a[j+1] then
begin
t := a[j];
a[j] := a[j+1]; a[j+1] := t
end
end
OR
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques
Dept of CSE
2025 - 26
PVPSIT (Autonomous)
Problem Solving Techniques