Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topological Sort Neil Tang 03/02/2010

Similar presentations


Presentation on theme: "Topological Sort Neil Tang 03/02/2010"— Presentation transcript:

1 Topological Sort Neil Tang 03/02/2010
CS223 Advanced Data Structures and Algorithms

2 CS223 Advanced Data Structures and Algorithms
Class Overview Basic concepts An application Algorithm 1 Algorithm 2 CS223 Advanced Data Structures and Algorithms

3 CS223 Advanced Data Structures and Algorithms
Basic Concepts A topological sort is an ordering of vertices in a DAG, such that if there is a path from vi to vj, then vj appears after vi in the ordering. The topological sort may not be unique for a DAG. Indegree/outdegree: the number of incoming/outgoing edges CS223 Advanced Data Structures and Algorithms

4 CS223 Advanced Data Structures and Algorithms
An Example Ordering 1: 1,2,5,4,3,7,6 Ordering 2: 1,2,5,4,7,3,6 CS223 Advanced Data Structures and Algorithms

5 CS223 Advanced Data Structures and Algorithms
An Application CS223 Advanced Data Structures and Algorithms

6 Topological Sort: Algorithm 1
Time complexity: O(|V|2) CS223 Advanced Data Structures and Algorithms

7 Topological Sort: Algorithm 2
Time complexity: O(|V|+|E|) CS223 Advanced Data Structures and Algorithms

8 Topological Sort: Algorithm 2
CS223 Advanced Data Structures and Algorithms


Download ppt "Topological Sort Neil Tang 03/02/2010"

Similar presentations


Ads by Google