Optimal Binary Variable-Length Codes with a Bounded Number of 1's per Codeword: Design, Analysis, and Applications
Roberto Bruno, Roberto De Prisco, Ugo Vaccaro
TL;DR
This work studies optimal average-length binary codes under a bound on the number of 1's per codeword, motivated by constrained search problems. It develops a dynamic programming framework and a Knuth–Yao speedup to achieve an overall O(n^2 D) time solution for constructing optimal constrained alphabetic/prefix codes and constrained binary trees. A Kraft-like condition extends classical bounds to the D-ones constraint, and the results yield a polynomial-time solution to constrained average-height trees, improving prior O(n^{2+D}) approaches. The findings clarify when the constraint truly affects optimality and offer practical methods for designing efficient, constrained encoding schemes with applications to search processes and data compression.
Abstract
In this paper, we consider the problem of constructing optimal average-length binary codes under the constraint that each codeword must contain at most $D$ ones, where $D$ is a given input parameter. We provide an $O(n^2D)$-time complexity algorithm for the construction of such codes, where $n$ is the number of codewords. We also describe several scenarios where the need to design these kinds of codes naturally arises. We also provide a Kraft-like inequality for the existence of (optimal) variable-length binary codes, subject to the above-described constraint on the number of 1's in each codeword.
