English
Source / code snippets

Quicksort-procs up/down now yet quicker! here for Float-Arrays

 

p.specht

proc QuickSortUp11400in3sec :parameters a![]:declare n&,p&,l&,r&,s&,sl&[],sr&[],w!
declare x!,i&,j&:n&=sizeof(a![]):s&=1:sl&[1]=0:sr&[1]=n&-1
while s&>0:l&=sl&[s&]:r&=sr&[s&]:s&=s&-1:while l&<r&:i&=l&:j&=r&:p&=(l&+r&)\2
if a![l&]>a![p&]:w!=a![l&]:a![l&]=a![p&]:a![p&]=w!:endif
if a![l&]>a![r&]:w!=a![l&]:a![l&]=a![r&]:a![r&]=w!:endif
if a![p&]>a![r&]:w!=a![p&]:a![p&]=a![r&]:a![r&]=w!:endif:x!=a![p&]
while i&<=j&:while a![i&]<x!:inc i&:endwhile:while x!<a![j&]:dec j&:endwhile
if i&<=j&:w!=a![i&]:a![i&]=a![j&]:a![j&]=w!:inc i&:dec j&:endif:endwhile
if (j&-l&)<(r&-i&):if i&<r&:inc s&:sl&[s&]=i&:sr&[s&]=r&:endif:r&=j&:else
if l&<j&:inc s&:sl&[s&]=l&:sr&[s&]=j&:endif:l&=i&:endif:endwhile:endwhile
endproc

proc QuickSortDwn11000in3sec :parameters a![]:declare n&,p&,l&,r&,s&,sl&[],sr&[],w!
declare x!,i&,j&:n&=sizeof(a![]):s&=1:sl&[1]=0:sr&[1]=n&-1
while s&:l&=sl&[s&]:r&=sr&[s&]:s&=s&-1:while l&<r&:i&=l&:j&=r&:p&=(l&+r&)\2
if a![l&]>a![p&]:w!=a![l&]:a![l&]=a![p&]:a![p&]=w!:endif
if a![l&]>a![r&]:w!=a![l&]:a![l&]=a![r&]:a![r&]=w!:endif
if a![p&]>a![r&]:w!=a![p&]:a![p&]=a![r&]:a![r&]=w!:endif:x!=a![p&]
while i&<=j&:while a![i&]>x!:inc i&:endwhile:while x!>a![j&]:dec j&:endwhile
if i&<=j&:w!=a![i&]:a![i&]=a![j&]:a![j&]=w!:inc i&:dec j&:endif:endwhile
if (j&-l&)<(r&-i&):if i&<r&:inc s&:sl&[s&]=i&:sr&[s&]=r&:endif:r&=j&:else
if l&<j&:inc s&:sl&[s&]=l&:sr&[s&]=j&:endif:l&=i&:endif:endwhile:endwhile
endproc
 
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/15/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.532 Views

Untitledvor 0 min.
Erhard Wirth06/14/24
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie