Question: Write this in C# language. Part C: Huffman Codes ( 4 0 marks ) Background In 1 9 5 2 , David Huffman published a
Write this in C# language.
Part C: Huffman Codes marks
Background
In David Huffman published a paper called "A Method for the Construction of MinimumRedundancy Codes". It was a seminal paper. Given a text of characters where each character occurs with a frequency greater than Huffman found a way to encode each character as a unique sequence of s and s such that the overall length number of bits of the encoded text was minimized.
Huffman recognized that characters with a greater frequency should have shorter codes than those with a lower frequency. Therefore, to disambiguate two codes, no shorter code of s and s can serve as the prefix beginning of a longer code. For example, if letter a has a code of no other character can have a code that begins with
To find these codes, a Huffman tree is constructed. The Huffman tree is a binary tree where the left edge of each node is associated with the number and the right edge is associated with the number All characters are stored as leaf nodes and the code associated with each character is the sequence of s and s along the path from the root to the character.
Requirements
As a start, read up on Huffman Codes in your text. Then, implement the Huffman class which tackles each of the following tasks.
Task : Determine the Character Frequencies
Determine the frequency of each character in the given text and store it in an array using the character itself to map to an index. Assume all printable ASCII characters, codes to may be used as part of the text see AnalyzeText
Task : Build the Huffman Tree
Using a priority queue of binary trees, a Huffman tree is constructed for the given text. Initially, the priority queue is populated with as many as individual nodes binary trees of size where each node stores a character and its frequency. The priority queue is ordered by frequency where a binary tree with a lower total frequency has a higher priority than one with a higher total frequency see Build
Task : Create the Codes
The final Huffman tree is then traversed in a prefix manner such that the code for each character is stored as a string of s and s and placed in an instance of the C# Dictionary class using its associated character as the key see CreateCodes and the string as the value.
Task : Encode
Using the dictionary of codes, a given text is converted into a string of Os and s see Encode
Task : Decode
Using the Huffman tree, a given string of s and s to converted back into the original text see Decode
To help implement your program, consider the following skeleton of code.Page of
To help implement your program, consider the following skeleton of code.Page of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
