> For the complete documentation index, see [llms.txt](https://veriny.gitbook.io/berkeley/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://veriny.gitbook.io/berkeley/170/greedy.md).

# Greedy

Greedy algorithms build a solution iteratively using a sequence of local choices — it's another method of algorithm solving.

## Huffman Encoding

Suppose you have an alphabet $$\Sigma$$, and a text that use characters that come from $$\Sigma$$. The frequency of any given character is the number of times it ocurrs. We want to find an unambiguous way for encoding the string.

### Prefix Free Encoding

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.

## Union Find
