Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Binary Tree Preorder Traversal
Bookmark
Input
Small (5 nodes)
Example 1
Complete Tree
Custom
tree
=
[4, 2, 5, 1, 3]
4
2
5
1
3
stack
result
preorder:
root
then left then right
algo
master
.
io
Step:
Start: preorder traversal (root, left, right) with a stack
0 / 20
Input
Small (5 nodes)
Example 1
Complete Tree
Custom
tree
=
[4, 2, 5, 1, 3]
0 / 20
4
2
5
1
3
stack
result
preorder:
root
then left then right
algo
master
.
io
Step:
Start: preorder traversal (root, left, right) with a stack