Abstract

In the partial alphabetic tree problem we are given a multiset of non-negative weights W = { w 1 , … , w n } , partitioned into m ⩽ n blocks B 1 , … , B m . We want to find a binary tree T where the elements of W reside in its leaves such that if we traverse the leaves from left to right then all leaves of B i precede all leaves of B j for every i < j . Furthermore among all such trees, T has to minimize ∑ i = 1 n w i d ( w i ) , where d ( w i ) is the depth of w i 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 problem arises when we need 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 ( ( W sum W min ) 2 α log ( W sum W min ) n 2 ) time where W sum = ∑ i = 1 n w i , W min = min i w i , and α = 1 log ϕ ≈ 1.44 ( ϕ = ( 5 + 1 ) 2 ≈ 1.618 is the golden ratio). 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 ( W sum / W min ) + 0.56 ⌋ 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 = { w 1 , … , w n } , and a multiset of integers D = { d 1 , … , d k } . We look for a forest F with k trees, T 1 , … , T k , where the weights in W correspond to the leaves of F, that minimizes ∑ i = 1 n w i d F ( w i ) where d F ( w i ) is the depth of w i in its tree plus d j if w i ∈ T j . Our algorithm for this problem runs in O ( k n 2 ) time.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call