5 ms·
“Prefix code” is sufficient for the problem to be well-defined, but I don’t think it is necessary. For a trivial counterexample, consider an alphabet of .-
by Someone 7y ago
“Prefix code” is sufficient for the problem to be well-defined, but I don’t think it is necessary.
For a trivial counterexample, consider an alphabet of
.-
..-
...-
(And yes, it isn’t uniquely solvable in the case or Morse code, as shown by the counter example A = ET)
- hcs 7y agoThat's a prefix code, they're defined by no code word being a prefix of another (so if you put them in a trie the code words only appear on leaves). A trivial example is the reverse: _. _.. _... Which can be decoded by, at worst, reversing the string first. (Sorry if I've misunderstood your example)
- Someone 7y agoNo, you didn’t.