Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you will implement the Huffman encoding of English characters, using a combined list and binary tree data structure. The method should have
In this assignment, you will implement the Huffman encoding of English characters, using a combined list and binary tree data structure. The method should have the following signature public static String huffmanCoder(String inputFileName, String outputFileName); which will read and compress an input text file inputFileName, (based on the Huffman encoding produced on the input file) and output the compressed file in outputFileName NOTE: that these strings represent the file names, not content you need to perform file I/O The method will output the outcome of its execution, e.g., "OK", "Input file error", etc. The output file can simply contain the characters "O" and "1", instead of the binary bits. It means you are not required to use sophisticated binary bit operations to actually store the encoded characters. NOTE: Since, you will be translating each character into a sequence of zeros and ones, the sum representing the full character, your output file size will actually be significantly larger than the input file. Therefore, Decompressing a file is not required. The program should also print out (a) The Huffman encoding of characters in the form of a table of character/frequency/ character/frequency/encoding triples - one triple per line, with "." separating the elements, e.g a: 315: 10010 b 855: 1010 (b) The calculated amount of space savings (see below for details) You will need to use a Java's standard list facility but implement your own HuffmanNode class with the following fields inChar: the character denoted by the node. This is meaningful only for the leaf nodes of a Huffman tree so interior nodes can have garbage here. right: right child of a node in the Huffman tree In this assignment, you will implement the Huffman encoding of English characters, using a combined list and binary tree data structure. The method should have the following signature public static String huffmanCoder(String inputFileName, String outputFileName); which will read and compress an input text file inputFileName, (based on the Huffman encoding produced on the input file) and output the compressed file in outputFileName NOTE: that these strings represent the file names, not content you need to perform file I/O The method will output the outcome of its execution, e.g., "OK", "Input file error", etc. The output file can simply contain the characters "O" and "1", instead of the binary bits. It means you are not required to use sophisticated binary bit operations to actually store the encoded characters. NOTE: Since, you will be translating each character into a sequence of zeros and ones, the sum representing the full character, your output file size will actually be significantly larger than the input file. Therefore, Decompressing a file is not required. The program should also print out (a) The Huffman encoding of characters in the form of a table of character/frequency/ character/frequency/encoding triples - one triple per line, with "." separating the elements, e.g a: 315: 10010 b 855: 1010 (b) The calculated amount of space savings (see below for details) You will need to use a Java's standard list facility but implement your own HuffmanNode class with the following fields inChar: the character denoted by the node. This is meaningful only for the leaf nodes of a Huffman tree so interior nodes can have garbage here. right: right child of a node in the Huffman tree
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