Thanks. The "package-merge" algorithm by Lawrence Larmore and Daniel
Hirschberg runs in O(n*L) algorithm, where n is the number of symbols
and L is the maximum code length. There's also the "warm-up"
algorithm, which is not optimal but produces optimal results in many
cases and has a provable worst bound.[2, 3].
In the case of gzip, replacing the existing algorithm with an optimal
algorithm such as package-merge produces a minimal benefit. The best
result reported in  is that using the package-merge algorithm
reduced the size of a compressed file from 1,817,536 bytes to 1,817,533
bytes, a savings of 0.00017%. On the hand, in the example I gave at
the start of the thread, using an optimal algorithm reduced the size
of the compressed data by 6.4%, so there are values of L and n for
which using an optimal algorithm will produce a significant benefit.
 A Fast Algorithm for Optimal Length-Limited Huffman Codes, by
Lawrence L. Larmore and Daniel S. Hirschberg
 The WARM-UP Algorithm: A Lagrangean Construction of Length
Restricted Huffman Codes, by Ruy Luiz Milidiu, Eduardo Sany Laber
 Efficient Implementation of the WARM-UP Algorithm for the
Construction of Length-Restricted Prefix Codes, by
Ruy Luiz Milidiu, Artur Alves Pessoa, Eduardo Sany Laber
 Improved GNU gzip Data Compression, by Roger Sayle