Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: Determine the Character Frequencies Determine the frequency of each character in the given text and store it in an array. For simplicity, only

Task 1: Determine the Character Frequencies Determine the frequency of each character in the given text and store it in an array. For simplicity, only lowercase letters from a to z, upper-case letters from A to Z, and the blank (space) are admissible as characters (see AnalyzeText).

Task 2: 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 53 individual nodes (binary trees of size 1) 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 3: 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 0s and 1s, and placed in an instance of the C# Dictionary class using its associated character as the key (see CreateCodes). Task 4: Encode Using the dictionary of codes, a given text is converted into a string of 0s and 1s (see Encode). Task 5: Decode Using the Huffman tree, a given string of 0s and 1s to converted back into the original text (see Decode). To help implement your program, consider the following skeleton of code.

class Node : IComparable { public char Character { get; set; } public int Frequency { get; set; } public Node Left { get; set; } public Node Right { get; set; } public Node (char character, int frequency, Node left, Node right) { } // 5 marks public int CompareTo ( Object obj ) { } } class Huffman { private Node HT; // Huffman tree to create codes and decode text private Dictionary D; // Dictionary to encode text // Constructor public Huffman ( string S ) { } // 15 marks // Return the frequency of each character in the given text (invoked by Huffman) private int[ ] AnalyzeText ( string S ) { } // 20 marks // Build a Huffman tree based on the character frequencies greater than 0 (invoked by Huffman) private void Build ( int[ ] F ) { PriorityQueue PQ; } // 20 marks // Create the code of 0s and 1s for each character by traversing the Huffman tree (invoked by Huffman) private void CreateCodes ( ) { } // 10 marks // Encode the given text and return a string of 0s and 1s public string Encode ( string S ) { } // 10 marks // Decode the given string of 0s and 1s and return the original text public string Decode ( string S ) { } } // Source documentation (comments) // 10 marks // Testing // 10 marks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago