← Tree Traversal

Micro-Drill #59 — Count nodes

Tree Traversal Target: 10s

Recursive node counting teaches divide-and-conquer tree thinking.

def count(node):
    if not node: return 0
    return 1 + count(node.left) + count(node.right)

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #58 Micro #60 →