COS 226 Exercises on Digraphs

1. Give the preorder and postorder numbers when you run DFS on the following digraph.
0-1 1-2 1-7 2-0 2-4 3-2 3-4 4-5 4-6 4-7 5-3 5-6 7-8 8-6 8-7
Use the "standard" adjacency-lists representation. Recall that each edge is inserted at the beginning of the adjacency list of each endpoint.







2. Give the transitive closure matrix of the digraph in the previous question.






3. [Exercise 19.103] Show, in the style of Figure 19.26, the process of topologically sorting with the source queue algorithm (Program 19.8) the DAG

3-7 1-4 7-8 0-5 5-2 3-8 2-9 0-6 4-9 2-6 6-4 4-3 2-3
The queue is a standard FIFO queue.




4. Show, in the style of Figure 19.28, the DFS forests and the contents of the auxiliary vertex-indexed arrays when using Kosaraju's algorithm to compute the strong components of the digraph below

0-1 1-2 1-7 2-0 2-4 3-2 3-4 4-5 4-6 4-7 5-3 5-6 7-8 8-6 8-7
Use the standard adjacency lists representation (as in question 1). Also, draw the kernel DAG.