Graph Theory37 sections · 1633 units
Open in Course

Quiz: Tree Diameter

Knowledge check

Check Your Understanding

The diameter of a tree is the longest path between any 22 nodes. In a DFS-based solution, you track the 22 deepest subtrees at each node. Why do you need the 22 deepest and not just the deepest?

  1. A.The second deepest subtree is needed for space complexity reasons
  2. B.You need 22 subtrees to handle the case where the tree is unbalanced
  3. C.The deepest subtree alone gives the tree height, not the diameter
  4. D.The longest path through a node goes down into 22 different children, so you combine both depths
Start the roadmap to answer the quizzes and solve the challenges