was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

26 Visitors Online


 
...ein Array mit dem Shell Sort Algorithmus Sortieren?
Autor: Stormer
[ Tip ausdrucken ]  

Tip Bewertung (15):  
     


{
 The following procedure sorts an Array with the
 fast Shell-Sort algorithm.
 Invented by Donald Shell in 1959,
 the shell sort is the most efficient of the O(n2)
 class of sorting algorithms
}

{
 Die folgende Prozedur Sortiert ein Array mit
 dem schnellem Shell-Sort Algorithmus.
}

Procedure Sort_Shell(var a: array of Word);
var
  
bis, i, j, k: LongInt;
  h: Word;
begin
  
bis := High(a);
  k := bis shr 1;// div 2
  
while k > 0 do
  begin
    for 
i := 0 to bis - k do
    begin
      
j := i;
      while (j >= 0) and (a[j] > a[j + k]) do
      begin
        
h := a[j];
        a[j] := a[j + k];
        a[j + k] := h;
        if j > k then
          
Dec(j, k)
        else
          
j := 0;
      end// {end while]
    
end// { end for}
    
k := k shr 1; // div 2
  
end;  // {end while}

end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners