When NOT to Use

Avoid forcing this pattern

Avoid forcing this pattern when:

  • Graph with cycles: Trees are acyclic. If cycles exist, use graph algorithms with visited tracking instead.
  • Need to go from child to parent without parent pointers: Standard tree traversal goes down.

Going up requires parent pointers or path tracking.

  • Multiple paths between nodes: Trees have exactly one path between any two nodes. Multiple paths indicate a general graph.