Sortieren durch Zählen

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

*Folgendes Sortierverfahren findet sich im Band 3 des Werks ``The Art of Computer Programming'' von D. Knuth:
 
*Algorithm C (Comparison counting). This algorithm sorts R1, ···, RN on the keys K1, ···, KN by maintaining an auxiliary table COUNT[1], ···, COUNT[N ] to count the number of keys less than a given key. After the conclusion of the algorithm, COUNT[j] + 1 will specify the final position of record Rj.

*[Clear COUNTs.] Set COUNT[1] through COUNT[N ] to zero.
 
*[Loop on i.] Perform step C3, for i = N, N-1, ···, 2; then terminate the algorithm.
 
*[Loop on j.] Perform step C4, for j = i-1, i-2, ···, 1.
 
*[Compare Ki : Kj.] If Ki < Kj, increase COUNT[j] by 1; otherwise increase COUNT[i] by 1.
 

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 2004, 2005 Andreas Borchert, in HTML konvertiert am 18.02.2005