Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Subtree of Another Tree
Bookmark
Input
Example 1 (true)
Example 2 (false)
Custom
tree
=
[3, 4, 5, 1, 2]
,
subTree
=
[4, 1, 2]
root
3
4
5
1
2
subRoot
4
1
2
algo
master
.
io
Step:
Start: Check if subRoot is a subtree of root
0 / 6
Input
Example 1 (true)
Example 2 (false)
Custom
tree
=
[3, 4, 5, 1, 2]
,
subTree
=
[4, 1, 2]
0 / 6
root
3
4
5
1
2
subRoot
4
1
2
algo
master
.
io
Step:
Start: Check if subRoot is a subtree of root