Quiksort


()

Sub Sort(L,R)

i=l

j=r

x=A(( l+r ) div 2 )

while A( i ) < x do

i=i+1

end while

while A( j )>x do

j=j-1

end while

if i<=j then

Y=A( i )

A( i )=A( j )

A( j )=Y

while i>j do

if l<j then

sort( l,j )

end if

if i<r then

sort( i,r )

end if

return

sub Quiksort

sort ( 1, n )

return

: (n* log( n )).




- -  - -  - -