With this reduction, the algorithm is "O(nL)"-time and "O(nL)"-space. However, the original paper, ""A fast algorithm for optimal length-limited Huffman codes"", shows how this can be improved to "O(nL)"-time and "O(n)"-space. The idea is to run the algorithm a first time, only keeping enough data to be able to determine two equivalent subproblems that sum to half the size of the original problem. This is done recursively, resulting in an algorithm that takes about twice as long but requires only linear space.