Greedy
Last updated
Was this helpful?
Last updated
Was this helpful?
Greedy algorithms build a solution iteratively using a sequence of local choices — it's another method of algorithm solving.
Suppose you have an alphabet , and a text that use characters that come from . The frequency of any given character is the number of times it ocurrs. We want to find an unambiguous way for encoding the string.
In order to encode our string in such a way that it is not ambiguous, we can just encode it such that no character's encoding is a prefix of any other character's encoding.