Skip to main content

11. Symmetric Tree

easyAsked at Adobe

Determine whether a binary tree is a mirror of itself. Adobe asks this to test mirror-recursion intuition — the same logic that flips paths and shapes across the vertical axis in vector graphics editors.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Adobe loops.

  • Glassdoor (2026-Q1)Adobe SDE-I phone screens include this for tree recursion.

Problem

Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).

Constraints

  • The number of nodes in the tree is in the range [1, 1000].
  • -100 <= Node.val <= 100

Examples

Example 1

Input
root = [1,2,2,3,4,4,3]
Output
true

Example 2

Input
root = [1,2,2,null,3,null,3]
Output
false

Approaches

1. Inorder traversal + palindrome check

Inorder-traverse, check if result is a palindrome.

Time
O(n)
Space
O(n)
// Inorder of asymmetric trees can coincidentally be palindromic — this approach is FRAGILE.
// Mention only to discard.

Tradeoff: Doesn't work in general — null markers needed. Mention as a trap to avoid.

2. Mirror-recursion pair compare

Recurse on (left.left, right.right) and (left.right, right.left). Two subtrees are mirrors iff vals match and both cross-pairs are mirrors.

Time
O(n)
Space
O(h)
function isSymmetric(root) {
  function isMirror(a, b) {
    if (!a && !b) return true;
    if (!a || !b) return false;
    return a.val === b.val
      && isMirror(a.left, b.right)
      && isMirror(a.right, b.left);
  }
  return isMirror(root, root);
}

Tradeoff: The 'cross-pair' recursion — left.left vs right.right, left.right vs right.left — is the entire trick. Adobe interviewers grade whether you arrive at this without prompting.

Adobe-specific tips

Adobe values the moment when you say 'I'll pass two nodes into the helper and recurse on the cross-pairs.' Mention that this same mirror-recursion is what powers 'flip horizontal' on a vector shape's path tree.

Common mistakes

  • Recursing same-side pairs (left.left vs right.left) — that's same-tree, not symmetric.
  • Forgetting both nulls case — fails on empty subtrees.
  • Trying to do it via traversal without null markers — coincidence palindromes break it.

Follow-up questions

An interviewer at Adobe may pivot to one of these next:

  • Same Tree (LC 100).
  • Invert Binary Tree (LC 226).
  • Make a function that returns the mirrored tree, not just a boolean.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why pass root, root initially?

The two arguments represent 'left side' and 'right side' of the comparison. The whole tree is symmetric iff it is its own mirror, so we kick off comparing root against itself.

Can I do this iteratively?

Yes — use a queue or stack and push pairs. Each iteration pops a pair and pushes the two cross-pair comparisons.

Practice these live with InterviewChamp.AI

Drill Symmetric Tree and other Adobe interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →