need help on how to encode words using huffman code

前端 未结 4 769
野的像风
野的像风 2021-01-14 06:26

how do you encode words using the huffman code such as NEED

4条回答
  •  Happy的楠姐
    2021-01-14 07:33

    I think you mean Huffman Coding. It's an algorithm to compress data without loss. Put simply, you replace the longest and most repetitious contiguous bits of data to the smallest possible representation (which is how most compression works). For example, an HTML page might assign the very common to the binary number 01 reducing the 32 bits of every to just 2 bits.

    That's the basic idea. The other trick is how to pick the numbers so you don't need to use a fixed size or a separator. This is done using a Huffman Tree. Read the Wikipedia article for more.

提交回复
热议问题