Preorder and Postorder
Explore preorder and postorder traversal techniques using depth-first search on graphs. Understand the timing and classification of vertices and edges during DFS, including concepts like active intervals and ancestor-descendant relationships. This lesson helps you implement DFS with traversal orders and analyze graph structures effectively.
We'll cover the following...
Hopefully, you are already familiar with preorder and postorder traversals of rooted trees, both of which can be computed using depth-first search. Similar traversal orders can be defined for arbitrary directed graphs even if they are disconnected by passing around a counter, as shown below. Equivalently, we can use our generic depth-first search algorithm with the following subroutines: , , and .
Algorithm
...