• Keine Ergebnisse gefunden

Algorithm Engineering „Schnelles Sortieren“

N/A
N/A
Protected

Academic year: 2021

Aktie "Algorithm Engineering „Schnelles Sortieren“"

Copied!
55
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Algorithm Engineering

„Schnelles Sortieren“

Stefan Edelkamp

(2)

Überblick

Kriterien für Sortierverfahren

State-of-the-Art

Clever-Quicksort

Heapsort

Weak-Heapsort

Quick-Heapsort

Radix-Exchange-Sort

Sortieren durch Fachverteilung

(3)

Kriterien für Sortierverfahren

(4)

State-of-the-Art

(5)

State-of-the-Art (2)

(6)

State-of-the-Art (3)

(7)

Clever-Quicksort (Median-of-3)

(8)

Clever-Quicksort (Median-of-3)

Σ

(9)

Implementierung Siehe Sedgewick:

The analysis of quicksort

programs, Acta Informatica,

Journal of Algorithms,

15(1):76-100,

1993

(10)

Heapsort

(11)

Definition

(12)

Veranschaulichung

(13)

Entfernen

des Maximums

(14)

Versickern

(15)

Pseudo-Code

(16)

Erstellung eines Heaps

(17)

Äußere Schleife

(18)

Analyse Iteriertes Versickern

Σ

(19)

Analyse

(20)

Beobachtung

(21)

Bottom-Up-

Heapsort

(22)

Pseudo-Code (1)

(23)

Pseudo-Code (2)

(24)

Worst-Case

(25)

Average Case

(26)

Weak-Heap-Sort

(27)

Verschmelzen

(28)

Generieren eines

Weak-Heaps

(29)

Sortierung

(30)

Arrayeinbettung

(31)

3 Fälle

(32)

Pseudo

Code

(33)

Analyse

Σ

(34)

Engineering

(35)

Quick-Heapsort

(36)

Quick-Heapsort

Σ Σ

(37)

Pseudo-Code

(38)

Pseudo-Code (2)

(39)

Pseudo-

Code (3)

(40)

Radix-

Sort

(41)

Radix-Exchange-Sort

(42)

Beispiel

(43)

Unterscheidene

Präfixe

(44)

Analyse

(45)

Sortieren durch

Fachverteilen

(46)

Analyse

(47)

Illustration

(48)

Pseudo-Code (1)

(49)

Pseudo-

Code (2)

(50)

Adaptives Sortieren

Inversionen Inv(X) = {(i,j) |

 1 <= i < j <= n und

 xi > xj}

Ziel AE:

1*n log (Inv(X)/n)+O(n) Wenn Inv(X) = O(n²) 

n log n + O(n)

Inversions-optimal := Laufzeit

 O(n log (Inv(X)/n)+n)

Informationstheoretische Grenze:

 Ω(n log (Inv(X)/n)+n)

(51)

Kartesischer Baum

 Der kartesische Baum TF

von F[1..n] ist ein geordneter „gewurzelter“

Baum mit n Knoten.

Der kartesische Baum des leeren Feldes ist der leere Baum. Sei k = min (1,n).

Die Wurzel von TF ist markiert mit k, die Kinder sind die kartesischen Bäume von

F[1..k −1] und F[k+1..n] (wobei F[i..j] das leere

Feld ist, falls j < i).

(52)

Konstruktion (a la wikipedia)

Process the sequence values in left-to-right order, maintaining the Cartesian tree of the nodes processed so far, in a

structure that allows both upwards and downwards traversal of the tree.

To process each new value x, start at the node representing the value prior to x in the sequence and follow the path from this node to the root of the tree until finding a value y smaller than x. This node y is the parent of x, and the

previous right child of y becomes the new left child of x.

The total time for this procedure is linear, because the time spent searching for the parent y of each new node x can be charged against the number of nodes that are removed

from the rightmost path in the tree

(53)

Levcopoulos–Petersson Algorithmus

 Konstruiere Karteschen Baums für die Eingabe

 Initialisiere PQ mit der Wurzel des kartesischen Baumes

 Solange PQ nicht leer:

1. Finde und lösche den min. Wert x in PQ (DeleteMin) 2. Gebe x aus

3. Füge die Kinder von x im kartesischen Baum zu PQ hinzu (Insert)

(54)

Zeit

(55)

Vergleiche

Referenzen

ÄHNLICHE DOKUMENTE

In particular, we found that the number “8” is associated with plates with significantly higher winning bids, and the number “4” is associated with plates with significantly

The purpose of this study was to increase the awareness and reveal the potential of parotid metastasis of oral squamous cell carcinoma (OSCC), describe the characteristic of

In that case, Member States shall ensure that restructuring procedures are not automatically terminated and that, upon examining the prospects for achieving an agreement on

Service configuration presents us with the ability to (re)construct reusable methods and process patterns or blueprints to support service networks through the visualisation of

These units use software to control various vehicle functions. The software required was developed by the applicant itself or the applicant arranged for development

It฀ is฀ anticipated฀ that฀ the฀ information฀ provided฀ in฀ this฀ report฀ will฀ be฀ of฀ value฀ to฀ the฀ New฀ South฀ Wales฀.. government’s฀

We take the whole of this body of work as read, in what we present here, for the simple reason that we do not have the time to repeat it. We do not repeat it also because we have

Likewise equation 13 can only hold true in a society which reproduces itself equally perfectly and unchangingly (as Sraffa himself remarks) but with a fully