← Tree Recursion

Pattern Recognition Drill

#94 — Symmetric tree

Easy Advanced Trees

The Problem

Check if a binary tree is its own mirror image.

What approach would you use?

Think about it before scrolling down.

Key Signals

Tree Recursion

is_mirror(left, right): both null → True. One null → False. Values match AND subtrees mirror. O(n).

Alt: Queue / BFS

BFS with pairs: enqueue (left.left, right.right) and (left.right, right.left). Same O(n).

Common Trap

Don't just check if inorder traversal is a palindrome — that's necessary but not sufficient.

← #93 #95 →