Code archives/Algorithms/QuickSort

This code has been declared by its author to be Public Domain code.

Download source code

QuickSort by TFT (der Falke)2001
The Fast Quick Sort algo
Print
Print" BlitzBasic V 1.60"
Print
Print" QuickSort v0.4 (C) by TFT (der Falke) Rev.0001-2"
Print
Print" Code date 23.8.2001 / 24.8.2001"
Print" SerNr: 2001.0002-0
Print" EMail tft@optima-code.de
Print" Inter http://www.optima-code.de
Print
Delay 5000

Dim c(1000000)

For i=0To 1000000
c(i)=-Rnd(100000)
Next

t=MilliSecs()
a=quicksort(0,1000000)
t=MilliSecs()-t

Print "1000000 Element mit QickSort"
Print "Time "+Str$(t)

For i=0To 20
Print c(i)
Next

Repeat
Until KeyHit(1)

End

Function quicksort(l,r)
  Local p,q,h
  p=l
  q=r
  x=c((l+r)/2)
  Repeat
    While c(p)q Then Exit
	;SWAP------------------
	h=c(q)
	c(q)=c(p)
	c(p)=h
	;----------------------
    p=p+1
    q=q-1
    If q<0 Then Exit
  Forever 
  If l

Comments

4pac2004
"While c(p)q Then Exit" ?????????


DJWoodgate2004
Yes. The displayed html version has been crippled by various updates to forum functionality. The original file is Ok though, use the download .bb file link above the code listing.


Code Archives Forum