Download presentation

Presentation is loading. Please wait.

Published byJordon Boram Modified over 2 years ago

1
Topological Sort Example This job consists of 10 tasks with the following precedence rules: Must start with 7, 5, 4 or 9. Task 1 must follow 7. Tasks 3 & 6 must follow both 7 & 5. 8 must follow 6 & 4. 2 must follow 4. 10 must follow 2. Make a directed graph and then a list of ordered pairs that represent these relationships.

2
9 1 7 3 5 4 6 8 2 10 Tasks listed as ordered pairs: 7,1 7,3 7,6 5,3 5,6 6,8 4,8 4,2 2,10 Tasks shown as a directed graph.

3
Predecessor CountsSuccessors 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 1 1 1 2 2 2 0 0 0 0 8 2 3 6 8 136

4
Place all tasks that have zero predecessors in a “bag”. BAGBAG 4 5 7 9 Step 1. Remove any task from the bag and place in sorted list. BAGBAG 4 5 9 Step 2. Update Predecessor and Successor arrays as needed. Sorted List: 7,

5
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 0 1 1 1 1 2 0 0 0 10 8 2 3 6 8 Predecessor CountsSuccessors 136

6
Step 3. Add to bag any tasks that now have zero predecessors. BAGBAG 4 5 9 1 Step. 4. Repeat steps 1, 2, and 3 until all predecessor counts are -1. (We are performing a “loop” or repetition.)

Similar presentations

OK

Computer Science 112 Fundamentals of Programming II Overview of Collections.

Computer Science 112 Fundamentals of Programming II Overview of Collections.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on the elements of the short story Ppt on council of ministry of nepal Ppt on indian classical music Ppt on plasma tv technology Ppt on series and parallel circuits for kids Ppt on training and development of employees Ppt on cross-site scripting vulnerabilities Ppt on word association test saturday Ppt on section 188 of companies act 2013 Ppt on old testament history