An algorithm is given for finding the minimum weight extension of a prefix code. The algorithm runs in O(n(3)), where n is the number of codewords to be added, and works for arbitrary alphabets. For binary alphabets the running time is reduced to O(n(2)), by Using the fact that a certain cost matrix satisfies the quadrangle inequality. The quadrangle inequality is shown not to hold for alphabets of size larger than two. Similar algorithms are presented for finding alphabetic and length-limited code extensions. (C) 1998 Elsevier Science B.V.