Height of Binary Tree

Recursive DFS visualizer for maximum depth computation

Read Here
Step0/24
Computed0
Max Depth0
Back To Trees List

Python Code

1def maxDepth(root):
if root is None:
3 return 0
4 left_height = maxDepth(root.left)
5 right_height = maxDepth(root.right)
6 return 1 + max(left_height, right_height)
Current Line (2): Enter Function

Tree Structure

123456
Operation:CALL

Traversal Progress

Current Node

-

Current Depth

-

Current Height

0

Max Depth

0

Computed Node Heights

Node heights appear here...
Phase: Enter
Step 1: CALL

Processing Stack

Stack is empty. Click Next to begin!

Step Explanation

Ready to Start

Click "Next Step" to begin recursive height traversal. DFS computes height bottom-up.

  • > Each node returns 1 + max(left_height, right_height).
Unvisited
Left
Current
Right
Done