Maximal prefix codes and maximal length Let $X$ a maximal prefix code on an alphabet $A$, $m(X)$ its maximal length, $F = X \cap A^{m(X)}$ and $F’ \subseteq A^{m(X)}$. Let $X’ = X \setminus F \cup F’$ a maximal prefix code. Why is it true that $X’ = X$? In other words, why is it true that one cannot obtain a maximal prefix code from another maximal prefix code with same maximal length by changing only the words of maximal length? Any reference for this result?
I'll assume that a prefix code is a set of words in which no word is the prefix of any other, and &quot;maximal&quot; means it is impossible to add any word to the set and keep this property.
Let $w$ be a maximal-length word that is not in $X$. There are two possibilities:

At least one (shorter) word in $X \setminus F$ is a prefix of $w$, in which case we could not add $w$ even if we first remove all words in $F$ from $X$;
No (shorter) word in $X \setminus F$ is a prefix of $w$, in which case we could add $w$ to $X$ without needing to first remove any words in $F$, contradicting the assumption that $X$ is maximal.