SHARE
TWEET

Untitled

a guest Sep 20th, 2017 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure quick_sort(a,left,right)
  2. begin
  3. var integer: i,j,meta,par,app,left,right
  4. var array of integer: a[1...n]
  5. if(!(left<=right))then
  6.    meta:=(left+right)/2
  7.    par:=a[meta]
  8.    i:=left
  9.    j:=right
  10.    while(i<j)do
  11.       while(a[i]<par)do
  12.          i:=i+1
  13.          endwhile
  14.       while(a[j]>par)do
  15.          j:=j-1
  16.          endwhile
  17.       if(i<j)then
  18.           app:=a[i]
  19.           a[i]:=a[j]
  20.           a[j]:=app
  21.       endif
  22.     endwhile
  23.   if((right-j)<(j-left))then
  24.       quick_sort(a,j+1,right)
  25.       quick_sort(a,left,j)
  26.   else
  27.       quick_sort(a,left,j)
  28.       quick_sort(a,j+1,right)
  29.   endif
  30. end quick_sort
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top