This implementation uses depth-first search. The constructor takes time proportional to V + E
(in the worst case), where V is the number of vertices and E is the number of edges.
Afterwards, the preorder and postorder operations take constant time, and
reverse postorder operation takes take time proportional to V.
This implementation uses depth-first search. The constructor takes time proportional to V + E (in the worst case), where V is the number of vertices and E is the number of edges. Afterwards, the preorder and postorder operations take constant time, and
reverse postorder operation takes take time proportional to V.