Correctness of constructing optimal alphabetic trees revisited
Theoretical Computer Science
Compact labeling schemes for ancestor queries
SODA '01 Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms
Proceedings of the thirteenth annual ACM symposium on Parallel algorithms and architectures
Improved labeling scheme for ancestor queries
SODA '02 Proceedings of the thirteenth annual ACM-SIAM symposium on Discrete algorithms
A comparison of labeling schemes for ancestor queries
SODA '02 Proceedings of the thirteenth annual ACM-SIAM symposium on Discrete algorithms
Journal of Algorithms
Journal of Algorithms
Hi-index | 0.00 |
In the partial alphabetic tree problem we are given a multiset of nonnegative weights W = {w1, . . . ,wn}, partitioned into k 驴 n blocks B1, . . . , Bk. We want to find a binary tree T where the elements of W resides in its leaves such that if we traverse the leaves from left to right then all leaves of Bi precede all leaves of Bj for every i j. Furthermore among all such trees, T has to minimize 驴i=1n wid(wi), where d(wi) is the depth of wi in T. The partial alphabetic tree problem generalizes the problem of finding a Huffman tree over W (there is only one block) and the problem of finding a minimum cost alphabetic tree over W (each block consists of a single item). This fundamental problem arises when we want to find an optimal search tree over a set of items which may have equal keys and when we want to find an optimal binary code for a set of items with known frequencies, such that we have a lexicographic restriction for some of the codewords.Our main result is a pseudo-polynomial time algorithm that finds the optimal tree. Our algorithm runs in O((Wsum/Wmin)2驴 log(Wsum/Wmin)n2) time where Wsum = &Sigmai=1n wi, Wmin = mini wi, and 驴 = 1/log 驴 驴 1.44. In particular the running time is polynomial in case the weights are bounded by a polynomial of n. To bound the running time of our algorithm we prove an upper bound of 驴驴 log(Wsum/Wmim) + 1驴 on the depth of the optimal tree.Our algorithm relies on a solution to what we call the layered Huffman forest problem which is of independent interest. In the layered Huffman forest problem we are given an unordered multiset of weights W = {w1, . . . , wn}, and a multiset of integers D = {d1, . . . , dm}. We look for a forest F with m trees, T1, . . . , Tm, where the weights in W correspond to the leaves of F, that minimizes 驴i=1n widF (wi) where dF (wi) is the depth of wi in its tree plus dj if wi 驴 Tj. Our algorithm for this problem runs in O(kn2) time.