Question
Using Huffman code, we can compress the bits used for saving the characters in a file: Total bits used for saving the character in table
Using Huffman code, we can compress the bits used for saving the characters in a file:
Total bits used for saving the character in table 1 is 264 bits using standard ASCII 8 bits for 1 character.
Using Huffman code encoding in Table 2, the total bits used is 126 bits.
The problem:
Input: list of characters such as table 1
Output: total bits using Huffman code encoding (table 2)
Task: Design an algorithm in pseudocode/code to print the total bits using Huffman code encoding and write down the Algorithm analysis. The complexity of the algorithm must be in O(n) and proof it!
PS: you dont need to sort the input since the input is already sorted!
Table. 1. Characters count. Character Frequency E 1 F 1 Table 2. Character bit using Huffman code Character Bits Frequency Total Bits Space 3 4 12 A 3 4 12 H 1 S 3 4 M 1 12 D 4 2 8 1 R T G 4 1 2 8 Y 1 4 3 1 12 D 4 L 2 8 2 2 N 4 3 12 G L 4 2 O 2 8 4 0 Y 2 4 1 I 3 E 5 1 5 F N 3 5 1 5 4 H 5 1 5 Space A S M 5 1 5 4 4 R 5 1 5 T 5 1 5 Total: 126
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started