Tree

Asked atAAugnitoExpediaMeeshoMicrosoftTSTechMojo Solutions
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Ask for the required output and tree type.
  2. 02Choose DFS or BFS to match the requested order or property.
  3. 03State the per-node invariant or returned value.
  4. 04Cover null root and skewed depth.

Reference answer

Then expect these follow-ups

  • When is BFS preferable to DFS?

    Tests: traversal choice

  • How do you validate that an input is a tree?

    Tests: graphs

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question