quick sort en edi
Publicado por Kajuna (1 intervención) el 30/01/2002 20:27:19
hola me gustaria saber si alguien podria explicarme como hacer el algoritmo quick sort en add.muxas gracias.
Valora esta pregunta


0
procedure Quick_Sort (Array : in out Ada.Containers.Vectors.Vector; Low, High : Integer) is
Pivot, Temp : Integer;
Left, Right : Integer;
begin
if Low < High then
Pivot := Array (Low + (High - Low) / 2);
Left := Low;
Right := High;
while Left <= Right loop
while Array (Left) < Pivot loop
Left := Left + 1;
end loop;
while Array (Right) > Pivot loop
Right := Right - 1;
end loop;
if Left <= Right then
Temp := Array (Left);
Array (Left) := Array (Right);
Array (Right) := Temp;
Left := Left + 1;
Right := Right - 1;
end if;
end loop;
Quick_Sort (Array, Low, Right);
Quick_Sort (Array, Left, High);
end if;
end Quick_Sort;