For a block of bits, encode its count leading zeros result as a zero flag followed by low count bits . An all-zero block has ; otherwise . Two half-block encoders supply flags and low counts . Combine them using , , and for . A one-bit leaf has and no low count bits. Checking whether the upper half is nonzero, only the lower half is nonzero, or both halves are zero proves the formula.
All count bits are selected in parallel, so for circuit depth. The circuit size satisfies ; summing the work over levels gives . Sharing the all-zero flags avoids a serial adder along the critical path.
Use a hierarchical leading-zero counter. A block of bits returns a zero flag and low count bits : its count leading zeros result is the concatenation . Thus means that the block is entirely zero and ; otherwise and is its leading-zero count. A one-bit block needs just and no low count bits.
For a block of bits, run two such Boolean circuits on the upper and lower halves in parallel. Write their flags as and their low count bits as . Set
The last expression is a two-input multiplexer. When the upper half is nonzero, its count is already the answer and . When only the upper half is zero, supplies the contribution while the multiplexers supply the lower half's count. When both halves are zero, the answer is , representing . This special encoding avoids an adder on the critical path.
Each node adds constant circuit depth, even though it uses logic gates for its parallel multiplexers. Hence
Indeed the internal-node work is bounded by a constant times , and the leaves add . Delay is and size is , counting fixed-fan-in logic gates and the usual wire fan-out model.
Figure 1.
Leading-zero summaries combine in parallel: the input gives the four-bit count
. Internal nodes display their block length and encoded leading-zero count; leaves display the one-bit count. A count's first bit is the shared all-zero flag. The highlighted branch supplies the low count at the root. Details.