AlgoFrames

Who reports first?

Warm-up · Trace the algorithm · about 5 min

height runs on this tree, left child first. A node reports its height only after both children have reported. Click the first node to report, then put all nodes in the order they report.

Example 1

Input:

[["A","B","C","D","E",null,"F"]]

Output:

["D","E","B","F","C","A"]

Children report before their parent.

Constraints

  • The tree has 6 nodes, A to F
  • Calls go to the left child before the right child

Learn the idea first: Recursive problems on trees: height, size, mirror, paths, a visual lesson.

More Recursive problems on trees: height, size, mirror, paths problems