Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Symmetric Tree
Bookmark
Input
Symmetric Tree
Not Symmetric
Same Values, Not Mirror
Four Levels
Custom
tree
=
[1, 2, 2, 3, 4, 4, 3]
mirror
1
2
2
3
4
4
3
checks
isSymmetric(root)
: mirror image of itself?
mirror
1
2
2
3
4
4
3
checks
isSymmetric(root)
: mirror image of itself?
mirror
1
2
2
3
4
4
3
checks
2
2 = 2
, compare outer children
mirror
1
2
2
3
4
4
3
checks
2
3
3 = 3
, compare outer children
mirror
1
2
2
3
4
4
3
checks
2
3
∅
outer ✓
, compare inner children
mirror
1
2
2
3
4
4
3
checks
2
3
∅
∅
pair 3 mirrors
: return true
mirror
1
2
2
3
4
4
3
checks
2
3
∅
∅
outer ✓
, compare inner children
mirror
1
2
2
3
4
4
3
∅
∅
checks
2
3
∅
∅
4
∅
∅ = ∅
: return true
mirror
1
2
2
3
4
4
3
∅
∅
checks
2
3
∅
∅
4
∅
∅
∅ = ∅
: return true
mirror
1
2
2
3
4
4
3
checks
2
3
∅
∅
4
∅
∅
pair 4 mirrors
: return true
mirror
1
2
2
3
4
4
3
checks
2
3
∅
∅
4
∅
∅
return true
algo
master
.
io
Step:
Start: is the tree a mirror image of itself?
0 / 15
Input
Symmetric Tree
Not Symmetric
Same Values, Not Mirror
Four Levels
Custom
tree
=
[1, 2, 2, 3, 4, 4, 3]
0 / 15
algo
master
.
io
Step:
Start: is the tree a mirror image of itself?