java编程代写 java程序代写 java代写 代写Java
Learning Outcomes
On successful completion of this assignment, students are expected to:
- understand and be able to apply a variety of data structures, together with their internal representation and algorithms;
- be able to make informed choices between alternative ways of implementation, justifying choices on grounds such as time and space complexity;
- be able to select, with justification, appropriate data structures to ensure efficient implementation of an algorithm.
To Do: Design and code a Java program that:
Requests from the user for a text filename to read the text inside, then it counts the frequency of each letter that file contains. There is no need to differentiate between upper and lower cases while punctuation marks are ignored. For this assignment purpose, the text file should be named as “Huff_in” with only letters inside. The program’s frequency table output should be like this:
a 12 c7
e 17 f4 k5 ......... u3
2. Based on the frequency table derived, a ternary Huffman codebook manager is implemented in your program that produces as output a codebook (in tabular format) that encodes letters based upon an input frequency table while the code generated should consume minimum bandwidth using these for codes: {0, 1, 2}, e.g. symbol ‘e’ is encoded as ‘0’, ‘a’ as ‘12’, ‘c’ as ‘112’, etc.
3. Corresponding ternary Huffman encoder & decoder are also implemented that carry out the encoding or decoding task based upon ternary codes received and a codebook as part of input. The encoder encodes input letters based on the specified codebook. The decoder will decode letters from ternary codes received using the codebook.
Coursework Submission
You should submit your Java program code files together with your report to the entry I provided on ICE. The submitted program solution should be well commented together with another 4-page report with a file name “Report.pdf” or “Report.doc” (or docx).
The input text file for your program to produce the corresponding Huffman output should be named as “Huff_in” which is a sample text file consisting of only text inside.
For my testing, I will be using various text file samples (in the same name as “Huff_in”) to test your program, by replacing the “Huff_in” file that you have tested.
Pls structure your program (named as “ter_Huff.java”) to include the following methods inside:
codeManager codeManager() generates & stores the Huffman codebook in some data structure(s) (to be designed by you) based on the input read from “Huff_in”.
encoder encoder() asks the user to input any text string (e.g. sampler) and it maps that string into ternary codes (i.e. code from this set: {0, 1, 2}); decoder
decoder asks the user to input any ternary code (e.g.
000211021) and it maps that code into the original text string.
main main()requests the user to make available “Huff_in” and then it reads from that file to produce the frequency output, and then it enters a loop for the user to choose to test try encoding/decoding by prescribing test data or producing output for the codebook until the user decides to exit.
You need to decide the signature for each method to ensure they interact well to accomplish the specified task.
