Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure QuickSort(const size: integer; var Comp,Perm: integer; var QA:TArray);
- Procedure QuickSort(L,R: Integer);
- var
- I,J,X,Y:Integer;
- begin
- I:=L;
- J:=R;
- X:=QA[(L+R) div 2];
- repeat
- // if not(QA[I]<X)then
- inc(comp);
- while QA[I]<X do
- begin
- Inc (I);
- inc(comp);
- end;
- // if not(QA[J]>X)then
- inc(comp);
- while QA[J]>X do
- begin
- Dec (J);
- Inc(Comp);
- end;
- // inc(comp);
- if I<=J then
- begin
- SWAP(QA,i,j);
- Inc(Perm);
- Inc (I);
- Dec (J);
- end;
- // inc(comp);
- until I>J;
- //inc(comp);
- if J>L then
- QuickSort(L,J);
- // inc(comp);
- if I<R then
- QuickSort(I,R);
- end;
- begin
- Comp:= 0;
- Perm :=0;
- QuickSort (0,size);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement