### Author Topic: Sortier-Algorithmen  (Read 3228 times)

#### Quentin

• Prof. Inline
• Posts: 915
##### Sortier-Algorithmen
« on: 2007-Dec-17 »
Nachtrag nach Forum-Umzug

Anm.: Seit SORTARRAY eigentlich ÃƒÂ¼berflÃƒÂ¼ssig

Code: (glbasic) [Select]
`DIM a[1000]FOR i = 0 TO 999  a[i] = RND(1000)NEXTt1 = GETTIMERALL()bubblesort(a[])t2 = GETTIMERALL()t3 = t2 - t1PRINT "Zeit fÃƒÂ¼r Bubble Sort: " + FORMAT\$(10, 2, t3) + " Millisekunden", 0 ,0SHOWSCREENKEYWAITWHILE TRUE  x = 0  y = 0  FOR i = 0 TO 999    PRINT a[i], x, y    INC y, 10    IF y > 470      y = 0      INC x, 30    ENDIF  NEXT  SHOWSCREENWEND// ------------------------------------------------------------- //// -=#  BUBBLESORT  #=-// ------------------------------------------------------------- //FUNCTION bubblesort: array[]  LOCAL count = BOUNDS(array[], 0) - 1  LOCAL notsorted = TRUE  LOCAL i, t    WHILE notsorted    notsorted = FALSE    FOR i = 0 TO count - 1      IF array[i] > array[i+1]        t = array[i]        array[i] = array[i+1]        array[i+1] = t        notsorted = TRUE      ENDIF    NEXT  WENDENDFUNCTION // BUBBLESORT`
« Last Edit: 2010-Jan-16 by Quentin »

#### Quentin

• Prof. Inline
• Posts: 915
##### Sortier-Algorithmen
« Reply #1 on: 2007-Dec-17 »
Die schnelle Sortiervariante: (abgekupfert bei einem Delphi-Listing)

Code: (glbasic) [Select]
`// --------------------------------- //// Project: sort// Start: Monday, August 20, 2007// IDE Version: 4.192DIM a[1000]FOR i = 0 TO 999  a[i] = RND(1000)NEXTt1 = GETTIMERALL()quicksort(a[], 0, BOUNDS(a[], 0) - 1)//bubblesort(a[])t2 = GETTIMERALL()t3 = t2 - t1PRINT "Zeit fÃƒÂ¼r Quicksort: " + FORMAT\$(10, 2, t3) + " Millisekunden", 0 ,0SHOWSCREENKEYWAITWHILE TRUE  x = 0  y = 0  FOR i = 0 TO 999    PRINT a[i], x, y    INC y, 10    IF y > 470      y = 0      INC x, 30    ENDIF  NEXT  SHOWSCREENWEND// ------------------------------------------------------------- //// -=#  QUICKSORT  #=-// ------------------------------------------------------------- //FUNCTION quicksort: array[], low, high  LOCAL lo, hi, piv, t    lo = low  hi = high  piv = array[high]  WHILE TRUE    WHILE array[lo] < piv       INC lo, 1     WEND    WHILE array[hi] > piv       DEC hi, 1     WEND    IF lo <= hi       t = array[lo]       array[lo] = array[hi]       array[hi] = t      INC lo, 1      DEC hi, 1    ENDIF    IF lo > hi THEN BREAK    WEND  IF hi > low THEN quicksort(array[], low, hi)  IF lo < high THEN quicksort(array[], lo, high)ENDFUNCTION // QUICKSORT`
« Last Edit: 2010-Jan-16 by Quentin »

#### Schranz0r

• Prof. Inline
• Posts: 5081
• O Rly?
##### Sortier-Algorithmen
« Reply #2 on: 2007-Dec-17 »
Irgendwie cool, auch wenn ich es atm nicht brauche!
I DGArray's

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

• Prof. Inline
• Posts: 1667
##### Sortier-Algorithmen
« Reply #3 on: 2007-Dec-18 »
Die Codes finde ich spitze! Darf ich sie (nur wenn du erlaubst) benutzen und mit meiner DB verbinden?
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

#### Quentin

• Prof. Inline
• Posts: 915
##### Sortier-Algorithmen
« Reply #4 on: 2007-Dec-18 »
dÃƒÂ¼rfen latÃƒÂ¼rnich frei verwendet werden, sonst stÃƒÂ¤nden sie nicht hier. Aber wie gesagt, sei SORTARRAY ÃƒÂ¼berflÃƒÂ¼ssig
« Last Edit: 2010-Jan-16 by Quentin »