79159016

Date: 2024-11-05 12:04:49
Score: 1.5
Natty:
Report link

As matszwecja stated there is no formal CS terminaology for this.

However, if you are referring to these definitions of bottom-up and top-down recursion then it is bottom-up:

Bottom-up recursion: Processes from the leaves up to the root, performing main computations after reaching the base cases.

Top-down recursion: Starts processing at the root and may pass information down to child nodes before completing recursive calls.

Why?

  1. The recursion first goes down to the leaf nodes by calling invertTree on root.left and root.right.
  2. At each leaf (or None node), it starts returning back up the recursive call stack.
  3. Once back ateach node, it swaps the left and right children after completing the recursive calls on both sides.
Reasons:
  • Blacklisted phrase (0.5): Why?
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: EuanG