Method and apparatus are configured to assign a code of less than N number
of bits in length to a pattern of bits of a first polarity value
distributed within a block of N binary bits. The method basically
comprises (1) determining a number of bits of the first value in the
block of N binary bits; (2) selecting a base value based on the
determined number of bits of the first value; (3) determining a
displacement value representative of a particular distribution of the
determined number of bits of the first value in the block of N binary
bits; and (4) adding the base value and the displacement value to obtain
a sum and using the sum to form an assigned code. The base value is
preferably selected by evaluating an Expression
Io=.sup.NC.sub.1+.sup.NC.sub.2+.sup.NC.sub.3 . . . +.sup.NC.sub.K-1,
wherein K is the determined number of bits of the first value in the
block of N binary bits. Determining the displacement value preferably
comprises (if bit N is a binary first value bit), recursively determining
the displacement value I(N,K) as .sup.N-1C.sub.K+I(N-1,K-1), where
I(N-1,K-1) is the encoding of the pattern of K-1 number of remaining
first value bits in N-1 bits. On the other hand, if bit N is not a first
value bit, determining the displacement value preferably comprises
recursively determining the displacement value I(N,K) as I(N-1,K) where K
is the encoding of the pattern of K number of first value bits in the
remaining N-1 number of bits.