Notes for week of 20050425
Dijkstra's Algorithm
Pseudocode
Minimum Spanning Tree
Minimum Spanning Tree Pseudocode
Final Exam Review
Red Black Trees
Merge Sort
Quick Sort
Sorting Algorithms for values in a subrange of numbers.
Data compression
Graphs
Distribution of questions.
Study
Cooperation
Cases
Strategy
Dijkstra's Algorithm
Shortest path from a source vertex to other vertices.
Pseudocode
Algorithm for Shortest Path (G, S, D)
Input
A weighted graph G. Paths start at S.
Output
An array D[U] such that D[U] will be the cought(??) of the shortest path from S
to U in G.
Initialize D[s] = 0 and D[U] = INF for each U != S.
Initialize Q = { all vertices in G }. Q is a list (queue). It is used to keep track of visited
vertices.
while Q is not empty do:
•
Get a vertex U from Q such that D[U] is the minimum among all vertices of Q.
•
For each vertex adjacent to U such that z is in Q do:
•
if D[U] + W[U,z] < D[z] then
•
D[z] = D[U] + W[U,z]
•
end if
•
end for
end while
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentLet m be number of edges and n be number of vertices. Then the complexity is either
O(n^2 + m) if we use a simple list or queue or O(n log n + m) if we use a heap.
Minimum Spanning Tree
Spanning tree with minimum total weight. Example: Connect all computers in the
building with the minimum amount of cable.
Properties
Let V' and V'' be a partition of the vertices of G. A partition is two sets of vertices that
are mutually exclusive.
Let (V', V'') be an edge across the partition, such that V' E V' and V'' E V''.
If the edge e = (v', v'') has the minimum weight across all the edges that join the
partition, then e = (v', v'') should be in the minimum spanning tree. In the previous
partition, the edge with weight of 8 should be in the minimum spanning tree (C, D).
This guarantees that the partition will be joined by the minimum edge.
Procedure
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Staff
 Algorithms, Graph Theory, Data Structures, Quick Sort, shortest path, weighted graph G.

Click to edit the document details