Geoinformation II Vorlesung 2 SS 2001 AVL-Bäume.

Slides:



Advertisements
Ähnliche Präsentationen
8. Termin Teil B: Wiederholung Begriffe Baum
Advertisements

Randomisierte Algorithmen Präfix Suche und Konsistentes Hashing
Punkt-in-Polygon-Verfahren III (R/R+-Baum)
Kap. 13 Sweep-Line Algorithmen Kap Schnittprobleme
Abbildungen Kapitel 4 Einführung in die Wirtschaftsinformatik von:
Mindesthöhe: |_log2 n_|, maximale Höhe: n-1
7. Natürliche Binärbäume
R. Der - Vorlesung Algorithmen und Datenstrukturen (Magister)
Balancierte Bäume Effizienz der Wörterbuchoperationen auf Bäumen hängt direkt von der Baumhöhe ab. Baum mit n Knoten: Mindesthöhe: |_log2 n_|, maximale.
Suche in Texten: Suffix-Bäume
WS Algorithmentheorie 05 - Treaps Prof. Dr. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (19 - Analyse natürlicher Bäume) Prof. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (27 – Kürzeste Wege) Prof. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (17 – Bäume: Grundlagen und natürliche Suchbäume) Prof. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (21 - AVL-Bäume: Entfernen, Bruder-Bäume) Prof. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (20 - Balancierte Bäume, AVL-Bäume) Prof. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (20 - AVL-Bäume: Entfernen, Bruder-Bäume) Prof. Th. Ottmann.
Algorithmen und Datenstrukturen
WS Prof. Dr. Th. Ottmann Algorithmentheorie 09 - Suche in Texten Suffix - Bäume.
Geometrisches Divide and Conquer
EINI-I Einführung in die Informatik für Naturwissenschaftler und Ingenieure I Vorlesung 2 SWS WS 99/00 Gisbert Dittrich FBI Unido
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II Vorlesung Foliendesign: cand. geod. Jörg Steinrücken.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Übung Diskrete Mathematik SS 2003 Segmentschnitt I.
Klausur „Diskrete Mathematik II“
Institut für Kartographie und Geoinformation Dipl.-Ing. J. Schmittwilken Diskrete Mathe II Übung
Diskrete Mathematik I Vorlesung 9b AVL-Baum, Algorithmen.
Institut für Kartographie und Geoinformation Diskrete Mathematik I Vorlesung Bäume-
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II Vorlesung In welcher Masche liegt der Punkt p?
Diskrete Mathe 9 Vorlesung 9 SS 2001
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung 1 SS 2001 Algorithmus von Dijkstra.
Animationen zu Kap. 4.3: AVL-Bäume
Diskrete Mathematik II
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II Vorlesung 8 SS 2000 Punkt-in-Polygon-Verfahren II (Trapezkarte)
Geoinformation II Vorlesung 4 SS 2001 Voronoi-Diagramme.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Objektorientierte Konzepte/UML Geoinformation I Vorlesung 2 WS 2000/2001.
Konstruktion der Voronoi-Diagramme II
Geoinformation II (6. Semester)
Geoinformation II Vorlesung 3 SS 2001 Polygon Overlay.
Diskrete Mathematik II
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung 5 SS 2001 Segmentschnitt II (n Segmente)
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II Vorlesung 7 SS 2000 Punkt-in-Polygon-Verfahren I (Trapezkarte)
Effiziente Algorithmen
Vorlesung Binärer Suchbaum II-
Vorlesung Mai 2000 Konstruktion des Voronoi-Diagramms II
Leistungskenngrössen V-243. Leistungskenngrössen V-244.
Abschlussball 2009 Übersicht Paare-Portraits
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation III Vorlesung 1 WS 2001/02 Punkt-in-Landkarte I (Streifenkarte)
Diskrete Mathematik II
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung 6 SS 2001 Segmentschnitt III.
Diskrete Mathematik II
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II 6. Sem. Vorlesung Mai 2000 Konstruktion des Voronoi-Diagramms.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Foliendesign: Jörg Steinrücken & Tobias Kahn Vorlesung
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Geoinformation II 6. Sem. Vorlesung April 2000 AVL-Bäume.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung Datenstrukturen für den Algorithmus von.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Foliendesign: Jörg Steinrücken & Tobias Kahn Vorlesung
Diskrete Mathe II Übung IKG - Übung Diskrete Mathe II – Jörg Schmittwilken 2 Übung5 Prüft, ob sich folgende Segmente schneiden: –P1(1/7) P2(3/1)
Binärer Suchbaum IV AVL-Baum I
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik I Vorlesung Binärer Suchbaum III- -AVL-Baum-
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Foliendesign: Jörg Steinrücken & Tobias Kahn Vorlesung
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung Voronoi-Diagramme.
Institut für Kartographie und Geoinformation Prof. Dr. Lutz Plümer Diskrete Mathematik II Vorlesung der Algorithmus von Floyd.
Binärer Baum, Binärer Suchbaum I
Geoinformation II 6. Sem. Vorlesung April 2000 Geometrische Algorithmen - ein einführendes, größeres Beispiel für ein Semester-begleitendes Programmier.
Diskrete Mathematik I Vorlesung 7 Binärer Suchbaum III.
Binärbäume.
Vorlesung April 2000 Polygon Overlay
Diskrete Mathematik II
Vorlesung AVL-Bäume/Algorithmen-
Vorlesung AVL-Bäume/Algorithmen-
Punkt-in-Landkarte II
 Präsentation transkript:

Geoinformation II Vorlesung 2 SS 2001 AVL-Bäume

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Übersicht I Einfacher Segmentschnitt I Verwaltung der aktiven Elemente letzte Stunde zur Erinnerung: Algorithmus Scan-Line Datenstrukturen für T und S Binärer Suchbaum Exkurs: AVL-Bäume AVL-Baum (Definition) AVL-Baum: Beispiel Balancefaktor Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Übersicht II AVL-Baum: Beispiel Einfügen von Knoten Löschen von Knoten L-Rotation LR-Rotation Exkurs: AVL-Bäume in Kürze Vollständige Bäume Minimale Knotenanzahl von AVL-Bäumen Fibonacci-Zahlen Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Übersicht III Minimale Knotenanzahl von AVL-Bäumen Maximale Höhe von AVL-Bäumen Das Wichtigste zu AVL in Kürze 4 Fälle im Überblick Zurück zur GIS Vorlesung Eine Variante des AVL-Baums für die Haltepunkte ... Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Einfacher Segmentschnitt I P2 P1 P3 P4 P2 P3 P4 P1 g g` P2 P1 P3 P4 S1 = det ( P1,P3,P4) Def.: Vor.: Alle Determinanten sind  0: S2 = det ( P3,P1,P2) g und g` schneiden sich genau dann, wenn S1, S2 S3 = det ( P2,P3,P4) sowie S3, S4 jeweils verschiedene Vorzeichen S4 = det ( P4,P1,P2) haben. Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Verwaltung der aktiven Elemente F B S2 S3 C S4 D A S1 E B E C D Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 letzte Stunde Scan-Line Hauptideen Projektion auf x-Achse Beschränkung auf aktive Elemente Ordnung der aktiven Elemente durch Scan-Line Beschränkung auf Nachbarn zum Schluß: 2-Segment-Schnitt (müßte Ihnen bekannt sein) heute: Datenstrukturen für Scan-Line Polygon-Overlay Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

zur Erinnerung: Algorithmus Scan-Line Input: S: eine Menge von Segmenten Output: die Schnittpunkte der Elemente von S Sei T = Endpunkte der Segmente von S nach x-Koordinaten sortiert (Haltepunkte) L =  // aktive Segmente von S while T   do bestimme und entferne den nächsten Punkt pT x ist x-Koordinate von p case: p ist linker Endpunkt von s fuege_ein(s,x,L) sl = vorgaenger(s,x,L) sr = nachfolger(s,x,L) schnitt(sl,s,T); schnitt(s,sr,T); p ist rechter Endpunkt von s sl = vorgaenger(s,x,L) sr = nachfolger(s,x,L) entferne(s,x,L) schnitt(sl,sr,T) p ist Schnittpunkt von s und t vertausche(s,t,L,x) // t < s sl = vorgaenger(t,x,L) sr = nachfolger(s,x,L) schnitt(sl,t,T) schnitt(s,sr,T) Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Datenstrukturen für T und S Datenstrukur für T AVL-Baum siehe diskrete Mathematik zur Erinnerung: was ist ein AVL-Baum erstens ein Suchbaum und zwar ein ausgeglichener Suchbaum Datenstruktur für L AVL-Baum? Vorgänger und Nachfolger Variante des AVL-Baums alle Informationen sind in Blättern (nicht in inneren Knoten) die Blätter bilden eine doppelt verkettete Liste Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Binärer Suchbaum Ein binärer Baum B ist ein binärer Suchbaum, falls er leer ist oder die folgenden Eigenschaften erfüllt sind: die beiden Unterbäume sind binäre Suchbäume die Beschriftungen der Knoten des linken Suchbaums sind kleiner als die Beschriftung der Wurzel die Beschriftungen des rechten Suchbaums sind größer als die Beschriftung der Wurzel n <n >n Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

siehe Vorlesung Nr. 9 Diskrete Mathe I Exkurs: AVL-Bäume siehe Vorlesung Nr. 9 Diskrete Mathe I

AVL-Baum (Definition) Ein binärer Baum heißt ausgeglichener Baum oder AVL-Baum (nach Adelson-Velskij und Landis), falls sich für jeden Knoten k die Höhen h der beiden Teilbäume um höchstens 1 unterscheiden. Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 AVL-Baum: Beispiel Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Balancefaktor Balancefaktor bal(k) bal(k) = h(rechter Teilbaum von k) - h(linker Teilbaum von k) Für AVL-Bäume gilt: bal(k) Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 AVL-Baum: Beispiel +1 -1 +1 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 AVL-Baum: Beispiel +1 -1 +1 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 AVL-Baum: Beispiel +2 +1 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 +1 8 20 3 11 17 33 26 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 26 39 17 20 33 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 26 39 17 20 33 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +1 20 26 39 33 17 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +1 20 26 39 33 17 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 17 20 +1 26 39 33 30 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 17 20 +1 30 26 39 33 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +1 20 -1 17 26 39 33 30 +1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +2 20 26 39 33 30 +1 -1 17 Ausgeglichenheit ist verletzt Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +2 20 26 39 33 30 +1 -1 17 Ausbalancieren durch Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 +2 8 20 -1 3 11 17 33 +1 26 39 R- Rotation 30 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +2 20 26 39 33 30 +1 -1 17 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 +2 8 20 -1 3 11 17 33 +1 26 39 30 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +2 20 26 30 39 33 17 L- Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 +2 20 17 26 30 39 33 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 +2 8 20 3 11 17 26 33 30 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 11 3 8 26 39 20 33 17 30 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten Einfügen von k = 30 +1 14 8 26 39 20 33 30 3 11 17 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Einfügen von Knoten +1 14 8 26 3 11 20 33 17 30 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 +1 8 20 3 11 17 33 26 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 +1 8 20 3 11 17 33 26 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 26 39 17 20 33 +1 8 3 11 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 8 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 11 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 11 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 11 14 -1 26 39 17 20 33 +1 11 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +1 Löschen von k = 11 14 26 39 17 20 33 +1 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +2 Löschen von k = 11 14 26 39 17 20 33 +1 3 L- Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +2 Löschen von k = 11 14 26 39 17 20 33 +1 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten +2 Löschen von k = 11 14 +1 3 20 17 33 26 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten 20 17 3 14 26 33 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Löschen von Knoten 20 14 33 3 17 26 39 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation Knoten x wird eingefügt und verletzt dadurch die Ausgeglichenheit an einem höher gelegenen Knoten k1 Notwendige Korrektur durch L-Rotation (symmetrisch: R-Rotation): Umhängen von zwei Kanten Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation +1 k1 k2 T1 T2 T3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation +2 T1 T2 T3 k1 k2 +1 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation T1 T2 T3 k1 k2 x +1 +2 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation +2 T1 T2 T3 k1 k2 +1 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 L-Rotation k2 k1 T3 T1 T2 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation x wird eingefügt und verletzt dadurch die Ausgeglichen- heit an einem höher gelegenen Knoten k1. Notwendige Korrektur durch LR- Rotation (symmetrisch: RL-, RR- und LL- Rotation): Umhängen von vier Kanten Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -1 k1 k2 T4 k3 T1 T2 T3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 +1 k2 +1 T4 k3 T1 T2 T3 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 T1 k2 x +1 T3 k3 T2 T4 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 T1 k2 x +1 T3 T4 k3 T2 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 +1 k2 +1 T4 k3 T1 T2 T3 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 T1 k2 x -1 T3 k3 T2 T4 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 T1 k2 x -1 T3 T4 k3 T2 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation -2 k1 -1 k3 -1 k2 T4 T3 T1 T2 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 LR-Rotation k3 -1 k1 k2 T2 T3 T1 T4 x Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Exkurs: AVL-Bäume in Kürze siehe Vorlesung Nr. 10 Diskrete Mathe I

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Übersicht Vollständige Bäume Minimale Knotenanzahl von AVL-Bäumen Fibonacci-Zahlen Maximale Höhe von AVL-Bäumen Das Wichtigste zu AVL in Kürze 4 Fälle im Überblick „Überleitung“ Güte von Algorithmen Groß-Oh-Notation Inklusion Komplexität - Beispiele Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Vollständige Bäume Ein binärer Baum heißt vollständig, wenn alle Blätter die gleiche Höhe haben. Ein vollständiger binärer Baum gegebener Höhe enthält die maximale Anzahl von Knoten. Wie groß ist die maximale Anzahl der Knoten eines vollständigen Baumes gegebener Höhe? Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Vollständige Bäume Anzahl innere Knoten Blätter Baum Höhe 1 1 2 1 2 3 3 4 ... h 2h-1-1 2h-1 S = 2h-1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Vollständige Bäume Satz: Ein vollständiger binärer Baum der Höhe h enthält 2h-1 Blätter und 2h-1 Knoten* (innere Knoten + Blätter!). Beweis: 1) Induktionsanfang: h= 1 Der Baum besteht nur aus der Wurzel, die auch das einzige Blatt ist: 21-1 = 20 = 1 Blatt 21-1 = 2 - 1 = 1 Knoten 2) Induktionsschritt: h  h + 1 Höhe h Höhe h + 1 2h-1 Blätter 2h Blätter 2h-1 Knoten 2h-1 innere Knoten S: 2h + 2h - 1 = 2h+1-1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Minimale Knotenanzahl von AVL-Bäumen N(h) sei die minimale Anzahl von Knoten eines AVL- Baumes der Höhe h. h = 1 N(1) = 1 h = 2 N(2) = 2 h = 3 N(3) = 4 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Minimale Knotenanzahl von AVL-Bäumen Allgemeiner Fall: 1 N(h-2) N(h-1) worst case der Höhe h: N(h) = N(h-1) + N(h-2) + 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 Fibonacci-Zahlen fib(0) = 0 fib(1) = 1 fib(2) = 1 ... fib(n) = fib(n-1) + fib(n-2) Abschätzung von fib: Sei Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Minimale Knotenanzahl von AVL-Bäumen Satz: N(h) = fib(h+2) - 1 Beweis: 1) Induktionsanfang: h = 1 fib(1+2) - 1 = fib(3) - 1 = 2 - 1 = 1 2) Induktionsschritt: h  h + 1 N(h+1) = 1 + N(h) + N(h-1) = 1+ fib(h+2) - 1 + fib(h+1) - 1 = fib(h+3) - 1 = fib([h+1]+2) - 1 1 N(h-1) N(h)

Maximale Höhe von AVL-Bäumen Daraus folgt nach Umformung der Abschätzung: Ein AVL-Baum mit n Knoten hat höchstens die Höhe 1,44...  log(n) + const Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze 1. Die { L, R, RL, LR } - Rotationen finden Anwendung, wenn bei der Rückkehr von den eingefügten/gelöschten Knoten zur Wurzel des Baumes ein Balance-Faktor {-2, +2 } gefunden wird. 2. Die Wiederherstellung der AVL-Eigenschaft involviert höchstens 3 Knoten + Verweise auf die Nachfolger.  Prinzip der Lokalität (Das Problem kann auch nur auf dem Weg von einem Blatt zur Wurzel des Baumes auftreten.) 3. Es finden nur vertikale Verschiebungen der involvierten Knoten statt. Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze Die Form eines Baumes hängt von der Eingabefolge ab: Eingabe von {1, 2, 3} Eingabefolge: 2, 1, 3 2 1 3 2 1 3 Eingabefolge: 2, 3, 1 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze Eingabefolge: 1, 2, 3 1 2 1 2 3 2 1 3 L-Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze Eingabefolge: 3, 2, 1 -2 1 2 3 R-Rotation 2 1 3 Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze Eingabefolge: 3, 1, 2 R 2 2 1 2 3 1 2 3 L 2 1 3 L-R-Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Das Wichtigste zu AVL in Kürze Eingabefolge: 1, 3, 2 2 2 L 3 2 1 3 2 1 R 2 1 3 R-L-Rotation Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 4 Fälle im Überblick Woher rührt die Verletzung der Balance am Knoten ? R LR RL L Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Zurück zur GIS Vorlesung

Eine Variante des AVL-Baums mit einer doppelt verketteten Liste der Blätter für die Menge der aktiven Elemente Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2

Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2 für die Haltepunkte ... ...mit den Operationen Einfügen eines gefundenen Schnittpunktes Finden und Entfernen des nächsten (also minimalen) Elements ... ... genügt ein „normaler“ AVL-Baum obwohl man mit Kanonen auf Spatzen schießt besser: ein Heap bei Interesse: Vorlesung 2 (heute), Diskrete Mathematik Lutz Plümer - Geoinformation - 6. Semester - SS 2001 - Vorlesung 2