Explain the difference between a weighted and non-weighted code.


Q.) Explain the difference between a weighted and non-weighted code.

Subject: digital circuit and system

Weighted Code

A weighted code is a code in which each symbol or bit is assigned a weight, and the average weight of all symbols is minimized. The weight of a symbol is typically a measure of its probability of occurrence, but it can also be a measure of its importance or cost.

Weighted codes are often used in data transmission and storage applications, where the goal is to minimize the average number of bits required to represent a sequence of symbols. This can be achieved by assigning shorter codes to more frequently occurring symbols and longer codes to less frequently occurring symbols.

The most common type of weighted code is the Huffman code, which is an optimal code in the sense that it minimizes the average code length for a given set of symbol probabilities. Other types of weighted codes include the Shannon-Fano code, the Elias code, and the Golomb code.

Non-Weighted Code

A non-weighted code is a code in which all symbols are assigned codes of equal length. This means that the average weight of all symbols is the same. Non-weighted codes are often used in applications where the simplicity of the code is more important than the efficiency of the code.

The most common type of non-weighted code is the fixed-length code, which is a code in which all symbols are assigned codes of the same length. Other types of non-weighted codes include the variable-length code, which is a code in which the length of the code for a symbol depends on the probability of occurrence of the symbol, and the self-synchronizing code, which is a code in which the code for each symbol is unique and can be easily synchronized with the start of a new codeword.

Comparison of Weighted and Non-Weighted Codes

The following table compares weighted and non-weighted codes:

Feature Weighted Code Non-Weighted Code
Average code length Minimized Constant
Complexity More complex Simpler
Efficiency More efficient Less efficient
Applications Data transmission and storage Simple applications

Conclusion

Weighted codes are more efficient than non-weighted codes, but they are also more complex. Non-weighted codes are simpler, but they are less efficient. The choice of which type of code to use depends on the specific application requirements.