12. Symmetric Tree
easyAsked at WorkdayGiven the root of a binary tree, check whether it is a mirror of itself. Workday uses this to extend the parallel-recursion pattern from Same Tree — useful for symmetrical permission policies in dual-approval workflows.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Workday loops.
- Glassdoor (2025)— Workday SDE2 phone screen.
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
root = [1,2,2,3,4,4,3]trueExample 2
root = [1,2,2,null,3,null,3]falseApproaches
1. Inorder serialize + reverse check
Inorder-serialize with null markers, check palindrome.
- Time
- O(n)
- Space
- O(n)
// serialize with explicit nulls, then compare with reversed serialization
// fragile — equal values on same depth on opposite sides may collideTradeoff: Brittle and slow. Don't.
2. Mirror-pair recursion
Compare left.left to right.right AND left.right to right.left.
- Time
- O(n)
- Space
- O(h) recursion
function isSymmetric(root) {
function mirror(a, b) {
if (!a && !b) return true;
if (!a || !b) return false;
if (a.val !== b.val) return false;
return mirror(a.left, b.right) && mirror(a.right, b.left);
}
return mirror(root, root);
}Tradeoff: Same as Same Tree but with the swap — left.left vs right.right is the only structural difference.
Workday-specific tips
Workday wants you to articulate that this is Same Tree with a swap. The cross-recursion (left.left <-> right.right) is the entire insight. Bonus signal: mention iterative version with a queue of pairs.
Common mistakes
- Comparing left to right at the top — that's same tree, not symmetric.
- Forgetting one cross (e.g., only doing left.left <-> right.right but not left.right <-> right.left).
- Starting with mirror(root.left, root.right) instead of mirror(root, root) — works but loses the elegant pattern.
Follow-up questions
An interviewer at Workday may pivot to one of these next:
- Iterative with a queue.
- Same Tree (LC 100) — same pattern, no swap.
- Invert Binary Tree (LC 226).
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why mirror(root, root) instead of mirror(root.left, root.right)?
Both work. mirror(root, root) is more uniform — the function compares two trees, and the special case is just that they start identical.
How would I do this iteratively?
Use a queue. Push (root, root). Pop pairs; on each, push (a.left, b.right) and (a.right, b.left). Fail on mismatched structure or values.
Practice these live with InterviewChamp.AI
Drill Symmetric Tree and other Workday interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →