Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Algorithmen und Komplexität Teil 1: Grundlegende.

Slides:



Advertisements
Ähnliche Präsentationen
Word Order in German Subordiante Clauses
Advertisements

Role Play Cards Edexcel B
Prof. Dr. S. Albers Prof.Dr.Th Ottmann
Christian Schindelhauer
Christian Schindelhauer
Algorithmen und Komplexität Teil 1: Grundlegende Algorithmen
Kapitel 9: Graphdurchlauf
Isolation: Serializability
Kontextfreie Grammatiken
Fakultät für informatik informatik 12 technische universität dortmund Mapping of Applications to Platforms Peter Marwedel TU Dortmund, Informatik 12 Germany.
Einführung in Berechenbarkeit und Formale Sprachen
Grammatiken, Definitionen
Algorithmen und Komplexität Teil 1: Grundlegende Algorithmen
Verifizieren versus Berechnen
1 HEINZ NIXDORF INSTITUT Universität Paderborn Algorithmen und Komplexität Einführung in Berechenbarkeit, Formale Sprachen und Komplexitätstheorie Wintersemester.
Algorithmen und Komplexität Teil 1: Grundlegende Algorithmen
WS Algorithmentheorie 13 - Kürzeste (billigste) Wege Prof. Dr. Th. Ottmann.
Vorlesung Informatik 2 Algorithmen und Datenstrukturen (27 – Kürzeste Wege) Prof. Th. Ottmann.
1 Vorlesung Informatik 2 Algorithmen und Datenstrukturen (21 – Kürzeste Wege) T. Lauer.
Wozu die Autokorrelationsfunktion?
Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Algorithmen und Komplexität Teil 1: Grundlegende.
Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Algorithmen und Komplexität Teil 1: Grundlegende.
Algorithmen und Komplexität Teil 1: Grundlegende Algorithmen
Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Algorithmen und Komplexität Teil 1: Grundlegende.
Christian Schindelhauer
Christian Schindelhauer
Three minutes presentation I ArbeitsschritteW Seminar I-Prax: Inhaltserschließung visueller Medien, Spree WS 2010/2011 Giving directions.
LS 2 / Informatik Datenstrukturen, Algorithmen und Programmierung 2 (DAP2)
Universität Karlsruhe (TH) © 2006 Univ,Karlsruhe, IPD, Prof. Lockemann/Prof. BöhmTAV 5 Chapter 5 Isolation: Serializability.
Kapitel 10: Graphalgorithmen
PageRank 1.What does the graph represent? 2.Describe PageRank. 3.What does PageRank measure in a graph? 4.Which role does PageRank play in IR?
This presentation is timed so you will only need to click on the left mouse button when it is time to move to the next slide. Right click on this screen.
Adjektive Endungen von Frau Templeton.
Relative clauses What is a relative clause?
Die Zeit (TIME) Germans are on military time which is 1-24
Institut AIFB, Universität Karlsruhe (TH) Forschungsuniversität gegründet 1825 Towards Automatic Composition of Processes based on Semantic.
Wenn sich eine Türe schließt,
Montag, den Hausaufgabe für Dienstag den Keine Hausaufgabe!!! Film: 8:00 oder 9:30 Guten Tag!
Das Perfekt (Present Perfect Tense). Think of 5 things you did in your holidays but think of sentences in the PRESENT TENSE. 1.Am Montag schlafe ich viel.
Dienstag, den Hausaufgabe für Mittwoch den IA 10.4 and printout LB 10.4 A-C Guten Tag!
Meine Schulfächer.
You need to use your mouse to see this presentation © Heidi Behrens.
You need to use your mouse to see this presentation © Heidi Behrens.
You need to use your mouse to see this presentation © Heidi Behrens.
Guten Morgen!.
Verben Wiederholung Deutsch III Notizen.
Miteinander Leben Deutch III Notizen Einheit 5. In this unit you will: Learn vocabulary for talking about relationships Learn vocabulary for various emotions.
The most obvious or direct use of auch is to mean also. Ich möchte auch Gitarre lernen. Auch ich möchte Gitarre lernen. I would like to learn Guitar. Someone.
Ein Herz besteht aus vielen Räumen, A heart consist of many rooms, Manche groß, Andere klein, Many big, others small, aber das soll nicht heißen, dass.
Welcome Instructor: Dominik Dwight Zethmeier
By: Jade Bowerman. German numbers are quite a bit like our own. You start with one through ten and then you add 20, 30, 40 or 50 to them. For time you.
STARTER Was passt nicht?
Alltagsleben Treffpunkt Deutsch Sixth Edition
Negation is when you dont have or dont do something.
Adjectiv Endungen Lite: Adjective following articles and pre-ceeding nouns. Colors and Clothes.
AVL-Trees (according to Adelson-Velskii & Landis, 1962) In normal search trees, the complexity of find, insert and delete operations in search.
Sentence Structure Subject and verb are always together. Subject and verb are always together. Subject and verb must agree Subject and verb must agree.
KIT – die Kooperation von Forschungszentrum Karlsruhe GmbH und Universität Karlsruhe (TH) Vorlesung Knowledge Discovery - Institut AIFB Tempus fugit Towards.
Present Tense Most regular verbs follow this pattern:
Separable Verbs Turn to page R22 in your German One Book R22 is in the back of the book There are examples at the top of the page.
Plusquamperfekt The past of the past.
1 Stevens Direct Scaling Methods and the Uniqueness Problem: Empirical Evaluation of an Axiom fundamental to Interval Scale Level.
THE PERFECT TENSE IN GERMAN
Adjective Endings Nominative & Accusative Cases describing auf deutsch The information contained in this document may not be duplicated or distributed.
How to use and facilitate an OptionFinder Audience Response System.
By Martin L. Loeffler.  The basic sentence has a subject and a verb.  The subject and verb need to be together.  The subject and verb need to agree.
Data Mining Spectral Clustering Junli Zhu SS 2005.
Adjective Declension in German
Programmiersprachen II Graph_Algorithmen Gewichtete Graphen - Minimum Spanning Tree und shortest path aus Implementierungssicht Prof. Dr. Reiner Güttler.
The Conversational Past
 Präsentation transkript:

Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Algorithmen und Komplexität Teil 1: Grundlegende Algorithmen WS 08/09 Friedhelm Meyer auf der Heide Vorlesung 5,

Friedhelm Meyer auf der Heide 2 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Organisatorisches Neuer Raum: Montags in P5.203 ist möglich, für Dienstag ist im Moment kein Hörsaal frei. Wir bleiben in F Übungen: Algorithmen sind immer zu kommentieren, Korrektheitsbeweis und Laufzeitanlyse (nicht nur Ergebnis) gehört dazu. Wir werden auf jedem Aufgabenblatt Aufgaben haben, in denen sie effiziente Algorithmen für Beispielprobleme finden und analysieren müssen.

Friedhelm Meyer auf der Heide 3 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy Algorithmen

Friedhelm Meyer auf der Heide 4 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithmen Wir wissen: Greedy-Algorithmen für z.B. Bruchteil Rucksack und Minimale Spannbäume sind optimal. Greedy-Algorithmen für z.B. 0-1 Rucksack ist sehr schlecht. Greedy-Algorithmen für z.B. Bin Packing (First Fit, Best Fit) sind 2-Approximationen, also gut, wenn auch nicht optimal. Kann man einem Problem ansehen, ob der zugehörige Greedy-Algorithmus optimal ist?

Friedhelm Meyer auf der Heide 5 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Matroide Sei E eine endliche Menge, U eine Familie von Teilmengen von E. (E,U) ist ein Teilmengensystem, falls gilt: 2 U Für jedes B 2 U ist auch jedes Aµ B 2 U. (Vererbungseigenschaft) (E,U) ist ein Matroid, falls zusätzlich gilt: Für alle A, B 2 U mit |A| < |B| gibt es x2 B mit A[{x} 2 U. (Austauscheigenschaft) B2U ist maximal, falls keine Obermenge von B in U ist. (Bem: in einem Matroid sind alle maximalem Mengen gleich groß.) Optimierungsproblem zu (E,U): Bestimme zu Gewichtsfunktion w:E ! R eine maximale Menge aus U mit maximalem Gewicht.

Friedhelm Meyer auf der Heide 6 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Teilmengensysteme und der kanonische Greedy-Algorithmus Der kanonische G.A. für Rucksack ist sehr schlecht (haben wir gezeigt) Der kanonische G.A. für MST ist optimal, haben sie in DuA gezeigt: Kruskals Algorithmus

Friedhelm Meyer auf der Heide 7 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Greedy-Algorithmen und Matroide

Friedhelm Meyer auf der Heide 8 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Noch ein interessantes Matroid: Matching für links-knotengewichtete bipartite Graphen Gegeben sei ein bipartiter, gewichteter Graph G=(L [ R, K, w) mit positiven Knotengewichten w(e) für die Knoten aus L. Ein Matching in G ist eine Menge von paarweise disjunkten Kanten. Ein maximales Matching ist eins mit maximalem Gewicht (seiner linken Knoten.)

Friedhelm Meyer auf der Heide 9 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Das bipartite-Matching Matroid Wähle E=L. Bµ L ist in U, falls es ein Matching mit linker Seite B in G gibt. Satz: (E,U) ist ein Matroid. Bew: (i) 2 U (klar) (ii) B 2 U, Aµ B ) A 2 U (klar) Wir müssen die Austauscheigenschaft nachweisen.

Friedhelm Meyer auf der Heide 10 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Beweis der Austauscheigenschaft Wähle E=L. Bµ L ist in U, falls es ein Matching mit linker Seite B in G gibt. Z.z.: Bew: Betrachte die Kantenmengen X und Y, die zu den Matchings für A und B gehören. Betrachte den durch X [ Y induzierten Graphen H. H besteht aus –isolierten Kanten, die rot, blau oder rot/blau sein können. –disjunkten Wegen, die aus abwechselnd roten und blauen Kanten bestehen. H hat mehr rote als blaue Kanten Also: Es gibt rote isolierte Kante (mit linkem Knoten v 2 B\A) oder Weg der Länge > 1 mit mehr roten als blauen Kanten.

Friedhelm Meyer auf der Heide 11 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Beweis der Austauscheigenschaft Also: Es gibt rote isolierte Kante (mit linkem Knoten v 2 B\A) oder Weg P der Länge > 1 mit mehr roten als blauen Kanten. Im ersten Fall: A [ {v} 2 U Im zweiten Fall: P hat ungerade Länge, beginnt und endet mit roter Kante v 2 B\A A [ {v} 2 U, da die roten Kanten ein Matching bilden.

Friedhelm Meyer auf der Heide 12 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Übungsaufgabe Nutzen sie obige Überlegungen, um einen effizienten Algorithmus zur Berechnung eines maximalen Matchings in einem (links Knoten-)gewichteten bipartiten Graphen anzugeben. Bem: Es ist auch nicht zu schwierig, maximale Matchings bzgl. Kantengewichten zu berechnen. (Augmenting Paths Methode; wir kommen darauf später zurück, wenn wir über Flussprobleme reden.) Die zugrunde liegende Struktur ist dann der Durchschnitt zweier Matroide.

Friedhelm Meyer auf der Heide 13 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Shortest paths problems

Friedhelm Meyer auf der Heide 14 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Shortest paths problems

Friedhelm Meyer auf der Heide 15 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Shortest paths problems

Friedhelm Meyer auf der Heide 16 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Negative edge weights In the sequel, we assume that there are no negative edge weights.

Friedhelm Meyer auf der Heide 17 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Single source shortest paths Dijkstras algorithm The algorithm works by keeping, for each vertex v of G, the cost d[v] of the shortest path found so far between s and v, and the current predecessor previous[v] on this path. Initialization: initSSSP(G,s) d[s]=0, d[v] = for all other vertices v ; Previous[v] = undefined for all vertices v. When the algorithm finishes, previous[v] should point to the predecessor of v on a shortest path from s to v, d[v] should be its length (or infinity, if no such path exists).

Friedhelm Meyer auf der Heide 18 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity initSSSP(G,s)

Friedhelm Meyer auf der Heide 19 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm The basic operation of Dijkstra's algorithm is edge relaxation for an edge (u,v): relax(u,v) If d(v) > d(u)+w(u,v) then begin d(v) is replaced by d[u]+w(u,v); previous[v] is replaced by u end relax(u,v) v u

Friedhelm Meyer auf der Heide 20 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm The algorithm maintains two sets of vertices S and Q. Set S contains all vertices v for which we know that the value d[v] is already the cost of a shortest path. Set Q contains all other vertices. Set S starts empty, and in each step one vertex is moved from Q to S. This vertex u is chosen as the vertex from Q with lowest value of d[u]. When a vertex u is moved to S, the algorithm relaxes every outgoing edge (u,v), i.e., invokes relax(u,v)

Friedhelm Meyer auf der Heide 21 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm

Friedhelm Meyer auf der Heide 22 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm Lemma: After each run of the while-loop, d(u) = (s,u) for each u 2 S. Clearly, this lemma implies the correctness. Decrease key

Friedhelm Meyer auf der Heide 23 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm, correctness Lemma: After each run of the while-loop, d(u) = (s,u) for each u 2 S. Proof: (i)Lemma holds for the first run, because then S={s} and d(s)= (s,s)=0. (ii)If x 1,..,x m is a shortest path, each sub-path x i,.., x j is one as well. Assume that the lemma does not hold. Let u be the first node inserted into S with d(u)> (s,u). By (i), s u. Consider a shortest path from s to u : Claim: d(y)= (s,y). Proof: u is the first node inserted into S with d(u)> (s,u). Thus d(x) = (s,x). When x was inserted into S, relax(x,y) was executed. Thus, after that operation, d(y) is the length of the path p 1 - y. By (ii), this is a shortest path.

Friedhelm Meyer auf der Heide 24 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm, correctness Lemma: After each run of the while-loop, d(u) = (s,u) for each u 2 S. Proof: (i)Lemma holds for the first run, because then S={s} and d(s)= (s,s)=0. (ii)If x 1,..,x m is a shortest path, each subpath x i,.., x j is one as well. Assume that the lemma does not hold. Let u be the first node inserted into S with d(u)> (s,u). By (i), s u. Consider a shortest path from s to u : We have shown: d(y)= (s,y) Thus d(y) = (s,y) · (s,u) < d(u). This contradicts the rule of Dijkstras algorithm: Choose the vertex u with lowest value of d[u] !!! (y would have been a better choice.)

Friedhelm Meyer auf der Heide 25 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm Decrease key

Friedhelm Meyer auf der Heide 26 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm Time bound: |V| times extract min, |E| times Decrease key dominate the runtime. Store Q in a linear array: Extract min time O(|V|), Decrease key time O(1) ) Time: O(|V| 2 + |E|) = O(|V| 2 ) Store Q in a Fibonacci-Heap: Extract min and Decrease key need time O(log(|V|)) ) Time: O((|V| + |E|) log(|V|)) = O(|E| log(|V|))

Friedhelm Meyer auf der Heide 27 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Dijkstras algorithm Animation in a geometric graph: Edge weight = Euclidean distance

Friedhelm Meyer auf der Heide 28 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Friedhelm Meyer auf der Heide Heinz Nixdorf Institute & Computer Science Department University of Paderborn Fürstenallee Paderborn, Germany Tel.: +49 (0) 52 51/ Fax: +49 (0) 52 51/ Thank you for your attention!