A
system and methods for generating full
binary tree codebooks for encoding data within one bit of the optimal expected
word length using only integer operations. The
system transforms the modified Shannon-Fano
algorithm into an implementation requiring only additions, subtractions, multiplications, and bit shifts, eliminating floating-point operations entirely. By tracking occurrence counts directly, replacing logarithmic calculations with most significant bit position detection, and using bit shifts instead of division, the method enables
codebook generation on ultra-low-power microcontrollers lacking floating-point units. The approach requires only four integer registers beyond the occurrence counters, maintains a full
binary tree structure ensuring every bit pattern of a given length is a valid codeword, and achieves compression performance within one bit of optimal. This implementation extends advanced compression capabilities to billions of resource-constrained devices including IoT sensors, wearables, and embedded systems where
power consumption and computational capacity are severely limited.