Hostname: page-component-74656f9884-rdgjk Total loading time: 0 Render date: 2026-11-09T13:00:43.842Z Has data issue: false hasContentIssue false

An optimal, purely functional implementation of the Garsia–Wachs algorithm

Published online by Cambridge University Press:  21 January 2020

RICHARD S. BIRD*
Affiliation:
Department of Computer Science, Oxford University, Wolfson Building, Parks Road, Oxford, OX1 3QD, UK (e-mail: bird@cs.ox.ac.uk)
Rights & Permissions [Opens in a new window]

Extract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the 'Save PDF' action button.

The Garsia–Wachs algorithm is an algorithm for building a binary leaf tree whose cost is as small as possible. The problem and the algorithm are described in more detail below, but the task is essentially the same as that of building a Huffman coding tree with the added constraint that the fringe of the tree has to be exactly the given list of inputs (in Huffman coding, the fringe of the tree can be any permutation of the input). As we will show below, the Garsia–Wachs algorithm can be implemented with a linearithmic running time—a running time of O (n log n) steps for an input of length n, the same time bound as for Huffman coding.

Information

Type
Functional Pearl
Copyright
© Cambridge University Press 2020
Submit a response

Discussions

No Discussions have been published for this article.