tanszek:oktatas:techcomm:huffman_codes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tanszek:oktatas:techcomm:huffman_codes [2024/10/07 07:39] kneheztanszek:oktatas:techcomm:huffman_codes [2024/10/07 07:53] (current) – [Steps in Huffman Encoding] knehez
Line 37: Line 37:
 Start with the frequencies: Start with the frequencies:
  
-{{:tanszek:oktatas:techcomm:pasted:20241007-073751.png?80%}}+{{:tanszek:oktatas:techcomm:pasted:20241007-073751.png}} 
 + 
 +First, combine the two lowest frequency nodes. Let’s combine C and H (both have frequency 1): 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074117.png}} 
 + 
 +Combine the two lowest frequency nodes: F and G 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074319.png}} 
 + 
 +Combine the two lowest frequency nodes: D and E 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074400.png}} 
 + 
 +Merging two nodes with lowest frequency: 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074452.png}} 
 + 
 +Merging two nodes with lowest frequency 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074521.png}} 
 + 
 +Merging two nodes with lowest frequency 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074548.png}} 
 + 
 +Final tree: 
 + 
 +{{:tanszek:oktatas:techcomm:pasted:20241007-074616.png}} 
 + 
 +=== Step 3: Assign Binary Codes === 
 + 
 +After building the tree, assign binary codes to each character by traversing the tree. Typically, moving left adds a 0, and moving right adds a 1. 
 + 
 +^Character^Binary Code^ 
 +|A|0| 
 +|B|100| 
 +|C|1100| 
 +|D|1110| 
 +|E|1111| 
 +|F|1010| 
 +|G|1011| 
 +|H|1101| 
 + 
 +Huffman encoded result: 
 + 
 +<code>BACADAEAFABBAAAGAH -> 100|0|1100|0|1110|0|....|1101</code> 
 + 
  
tanszek/oktatas/techcomm/huffman_codes.1728286765.txt.gz · Last modified: 2024/10/07 07:39 by knehez