60 likes | 200 Views
Unweighted Shortest Path Neil Tang 4/1/2008. Class Overview. The unweighted shortest path problem Breadth First Search (BFS) The algorithms Time complexity. Unweighted Shortest Path Problem.
E N D
Unweighted Shortest Path Neil Tang4/1/2008 CS223 Advanced Data Structures and Algorithms
Class Overview • The unweighted shortest path problem • Breadth First Search (BFS) • The algorithms • Time complexity CS223 Advanced Data Structures and Algorithms
Unweighted Shortest Path Problem • The unweighted shortest path problem: Given an unweighted graph G and a source vertex s, find a path from s to every other vertex in G with minimum number of edges. CS223 Advanced Data Structures and Algorithms
BFS CS223 Advanced Data Structures and Algorithms
An Algorithm • Time complexity: O(|V|2) CS223 Advanced Data Structures and Algorithms
Time Complexity • A bad case • More efficient implementation: Use a queue • Time complexity of a queue-based implementation: O(|V|+|E|) CS223 Advanced Data Structures and Algorithms