TEAM
HUFFMAN TREES
Mukti -
Team Nexus
Objectives :
Construction of Huffman Tree
Start with symbols as individual nodes
Repeatedly combine two smallest-weight nodes
New node weight = sum of children’s weights
Continue until one tree remains
(Include a step-by-step diagram)
PROPERTIES OF HUFFMAN TREE
Minimizes sum of (frequency × code-length) for all symbols
Yields optimal prefix code (no codeword is a prefix of another)
FILE COMPRESSION
▶ Lossless Compression:
▶ ZIP, GZIP, PNG use Huffman coding
▶ Lossy Compression:
▶ JPEG (images) and MP3 (audio) apply Huffman coding on quantized data
FAX MACHINE COMPRESSION
▶ Uses Modified Huffman coding
▶ Combines run-length encoding with Huffman coding
▶ Efficiently compresses black-and-white scan lines
ADAPTIVE HUFFMAN CODING
▶ Allows on-the-fly tree updates
▶ Applied to streaming or anomaly-detection scenarios
▶ Example: audio anomaly detection under concept drift
DEFINITION OF HEAP
A heap is a tree-based data structure
Heap property:
Max-heap: Each parent's key ≥ its children's keys
Min-heap: Each parent's key ≤ its children's keys
SHAPE PROPERTY
OPERATIONS
PRIORITY QUEUES
Applications:
Task scheduling
Event simulation
Interrupt handling
HEAPSORT
GRAPH ALGORITHMS
Min-heap to extract closest unvisited vertex
Heap for edge selection
Criterion | Huffman Tree | Heap |
Primary purpose | Static, optimal prefix‑code construction for lossless compression | Dynamic priority queue supporting repeated insertions/removals |
Key operations | Build once in O(n log n); encode/decode by tree traversal | Build in O(n); insert/extract in O(log n); peek in O(1) |
Use cases | File and data compression (ZIP, PNG, JPEG, GZIP, codecs), neural‑net pruning | Task scheduling, event simulation, Dijkstra/Prim, heapsort, k‑way merge |
Memory structure | Full binary tree of 2n–1 nodes (for n symbols) | Complete binary tree, stored as array of n elements |
Dynamic vs. static | Generally static once built; tree structure fixed for a data set | Dynamic: supports ongoing inserts/removals |
When better | Huffman tree: when needing optimal static coding for known symbol frequencies; compressing data permanently. | Heap: when requiring dynamic priority operations, frequent insert/extract; scheduling or streaming contexts. |