Recursion trace · Java

222. Count Complete Tree Nodes

Primary: value-combining Secondary: structure traversal Nodes labelled by heap index: children of #i are #2i and #2i+1

READY

Press Next to make the first call.

Source

Call stack newest on top

Recursion tree one node per call, drawn in call order

active on the stack perfect → formula null → 0 returned not called yet

The tree being counted

frame's node on the height probe counted by 2h−1 counted by a call never visited