0100. Same Tree

Easy — Tree, DFS, BFS

Recursive DFS
Iterative BFS (Queue)
Iterative DFS (Stack)
p = q =
▶ Press "Play" or "Step" to walk through the comparison.

Step

0 / 0

Comparisons

0

Time

Space

Default
Comparing
Match
Mismatch
Visited
Null
Algorithm Complexity
Recursive DFS
O(n)
O(n) / O(h)
Iterative BFS
O(n)
O(n) / O(w)
Iterative DFS
O(n)
O(n) / O(h)