← Tree Traversal

Micro-Drill #60 — Tree height

Tree Traversal Target: 10s

Height calculation is the basis for balanced-tree checks and diameter computation.

def height(node):
    if not node: return 0
    return 1 + max(height(node.left), height(node.right))

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #59 Micro #61 →