Graph Theory37 sections · 1633 units
Open in CourseQuiz: DFS State Tracking
Knowledge check
Check Your Understanding
You run DFS on a tree where each node stores a value. You want to count how many root-to-leaf paths have a sum greater than . Where in the DFS code should you check if the path sum exceeds ?
- A.Only at leaf nodes (nodes with no unvisited children)
- B.At every node during the traversal
- C.Only at the root before starting DFS
- D.After DFS finishes, using the returned values