A method and apparatus for detecting bits set in a data structure. A first
level encoding stage receives bits for the data structure, groups the bits
into a set of bit groups, and encodes the set of bit groups to form a set
of output bits. A set of intermediate level encoding stages is connected
to the first level encoding stage. Each level intermediate encoding stage
receives output bits from a previous stage, groups the output bits into a
plurality of bit groups, and encodes the plurality of bit groups to
generate a plurality of output bits. A final level encoding stage is
connected to a last intermediate level encoding stage within the set of
intermediate level encoding stages, wherein the final level encoding
receives final output bits from a last intermediate level encoding stage
within the plurality of intermediate level encoding stages and encodes the
final output bits to generate an indication of bits set in the data
structure.