Objective:
Build a basic file compression tool using Huffman Coding to understand data structures, file handling, and bitwise operations in C.
Concepts Covered:
✅ File handling (reading/writing binary files)
✅ Bitwise operations (manipulating individual bits)
✅ Data structures (priority queues, trees)
✅ Dynamic memory allocation
✅ Recursion
Step 1: Understanding Huffman Coding
Huffman coding is a lossless compression algorithm that assigns shorter codes to more frequent characters and longer codes to less frequent ones.
How It Works:
Count the frequency of characters in the file.
Build a min-heap (priority queue) of nodes where each node represents a character and its frequency.
Construct a Huffman tree by merging the least frequent nodes iteratively.
Generate Huffman codes from the tree (0s and 1s).
Encode the file using these codes.
Save the Huffman tree along with the compressed file for decoding later.