QuickSort

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Kryan

Betreff: QuickSort

BeitragSa, Feb 28, 2004 12:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi, falls ihr es noch nit habt:

Code: [AUSKLAPPEN]

 Function QuickSort(anzahl%,NumFeld%[anzahl%],Start%=0,Ende%=anzahl%)
 I%=Start%
 J%=Ende%
 X%=NumFeld[(I%+J%)\2]
 
 Repeat
  While NumFeld[I%]<X%
   I%=I%+1
  Wend
  While NumFeld[J%]>X%
   J%=J%-1
  Wend
 
  If I%<=J% Then
   a=NumFeld[I%]
   NumFeld[J%]
   NumFeld[I%]=NumFeld[J%]
   NumFeld[J%]=a
   I%=I%+1
   J%=J%-1
  EndIf
 Until I%>J%
 If J%>0 Then
  QuickSort(anzahl%,NumFeld,Start%,J%)
 EndIf
 If I%<anzahl% Then
  QuickSort(anzahl%,NumFeld,I%,Ende%)
 EndIf
End Function


Ich habe den Code grade von QB in BB übersetzt, falls Fehler vorkommen sollten postet einfach Wink
Webspaceanbieter?
Klick hier!
Kultige Spieleschmiede?
Klick hier!

DivineDominion

BeitragSa, Feb 28, 2004 12:28
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
Function QuickSort(anzahl%,NumFeld%[anzahl%],Start%=0,Ende%=anzahl%)


Was zum teufel - das geht?!

Nein, tut es nicht!
Ich denke du könntest den code zumidnest mal versuchen auszuführen. Nur in Notepad ohne Compiler codet sich das schlecht Wink
Davon abgesehen, dass du "\" zum Teilen nimmst anstatt "/", passt da überhaupt nichts.
christian.tietze@gmail.com - https://christiantietze.de
macOS

tft

BeitragSo, Feb 29, 2004 0:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi.....

versuch es doch mal damit.......

Code: [AUSKLAPPEN]

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)<x
      p=p+1
    Wend
    While x<c(q)
      q=q-1
    Wend
    If 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<q Then a=quicksort(l,q)
  If p<r Then a=quicksort(p,r)
  Return True
End Function



Wie man am Hider schon sieht......nicht gerade actuell...aber schnell.
TFT
https://www.sourcemagic.ch
Monkey,HTML5,CSS3,W 10 64 Bit, 32 GB Ram, GTX Titan, W8 ist Müll !!!!!!

tft

BeitragSo, Feb 29, 2004 0:22
Antworten mit Zitat
Benutzer-Profile anzeigen
?????
TFT
https://www.sourcemagic.ch
Monkey,HTML5,CSS3,W 10 64 Bit, 32 GB Ram, GTX Titan, W8 ist Müll !!!!!!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group