4 ms·
Indeed, though as the OP points out just below, if you have fixed frequencies, you don't have to sort. That said, you generally have fixed frequencies with a p
by SeveredCross 16y ago
Indeed, though as the OP points out just below, if you have fixed frequencies, you don't have to sort.
That said, you generally have fixed frequencies with a predetermined set of constraints on the data, and you can determine the most common character frequency (or it's already known). I'm not sure how common this is in real-world applications of Huffman coding.
Seeing as you should only be building the tree once though, you're right--you'd be hard-pressed to tell the difference between the two approaches, barring implementation mistakes. Designing an implementation mistake that would cause noticeable differences is an exercise left to the reader.