Table of Contents
CSE 589 Part II
Readings
Two basic paradigms
Example DP Problem: Matrix Chain Multiplication
It really does make a difference
Optimal parenthesization
Dynamic Program for Matrix Chain Multiplication
PPT Slide
DP for Matrix Chain Multiplication
Remarks
Example: Approximate String Matching
Dynamic Program for AST
PPT Slide
DP
To recover actual alignment
PPT Slide
Dynamic Programming Summary
Dynamic Programming Problem Surface Reconstruction
Dynamic Programming Problem Surface Reconstruction
PPT Slide
Graphs
PPT Slide
Definitions
Representing graphs for algorithms
PPT Slide
More Definitions: Assume n = |V|, e = |E|
Tree (undirected)
More definitions
Graph Searching
Breadth First Search (BFS)
PPT Slide
BFS Analysis
BFS Analysis
Consequences of BFS
Consequences of BFS
Consequences of BFS
Breadth First Search (BFS)
Spanning Trees
Breadth First Search (BFS)
Depth-First Search uses stack instead of queue
PPT Slide
DFS Analysis
Consequences of DFS
Most important property of DFS on undirected graphs
Consequences of DFS (cont.)
PPT Slide
Using DFS to get topological sort:
Modify DFS to solve topological sort problem
Consequences of DFS (cont.)
Other Applications of DFS
PPT Slide
Single-Source Shortest Paths (Dijkstra’s algorithm)
Idea of Dijkstra’s Algorithm:
Dijkstra’s Algorithm Assumption: c(u,v) = infinity if (u,v) not in E.
PPT Slide
Why is this algorithm correct?
At all times, for all v, Dist(v) is the length of shortest path from s to v that only goes through vertices in V-U
Run Time Analysis
Most priority queue implementations
Running time of Dijkstra’s algorithm:
Minimum Spanning Trees
Kruskal’s MST algorithm
Correctness
PPT Slide
To implement, use Disjoint Set ADT
Kruskal’s Algorithm with Disjoint Set ADT
Best result
Run-time of Kruskal’s Algorithm
Run-time of Kruskal’s Algorithm
Modeling the Problem
Your turn!!!!
Problems
Problems
Problems
|