Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me answer this simple coding question using JAVA. Please make sure that your code meets all the requirements and the output your code

Please help me answer this simple coding question using JAVA. Please make sure that your code meets all the requirements and the output your code gets is exactly the same as the sample test case output given below in the question. This is what I have so far but it doesn't take in user input and gives the wrong output for the second test case: pasted.co/e93ae8aa

You can simply modify what I already have to meet the requirements which are to take in user input and to get the correct output that matches the test cases.

image text in transcribed

_________________________________________________________________________

This is the sample inputs/outputs:

Sample Input 0

emma dora ruth ziegellaub eichler 0111010100101011110011110000101101111001001001010001011101011011000000011100110111110 

Sample Output 0

110011101111110100101011011100111101000010110111100100100101000101110101101100000001110011011111010011001011111110100000110001 miriam ruth ziegellaub 

Sample Input 1

this is a very very very long string about absolutely nothing but i need to have a larger example that is not easily worked out by hand to make sure your code works in the general case. can you tell i excelled in the humanities in school from this very fine piece of writing? 110100101110111101100111001001001010110101011111000010111110000010110000110000011111001000 

Sample Output 1

10101101010111110000101111100000111001100010101111110001001100010101111110001001100010101111110001001110110010110110111001110010101111110110110110111000111111101010011000010100001111111010111001001111011000010100101110110001000110100110101101010110110110111001111010100001010001011000110010010110011001010100100110100111110001010000111001110101111111111011101011111000101111011101111100001111011011101010001010110100111101000101111100000110100110100001001111110010111110110001001101100100111111110110101011001100100110000101000111101010001001101001110110110011001010100100110000011111011010100011100100001111101000100011001100001111100111100100111001101000110110010011111111011011110000101101100010101101001000110111010011001011111011111101001111000111111000101100100000111100011101100010001100110000001010010111011110100101100010111101111111000101110111101010110011001011011000101011010010001101010000110000011101101011101010110101110000101101100011100111100110101001100111101001100101111111001110000001010110101011111000011000101011111100010011001011011011001000111101101011010111100010001001110010100110110011111101110101011011011011111001001 hello? this is emma.
Implement a Huffman tree to encode and decode strings to and from variable-width encodings. Input Format The input will consist of two lines. The first line will be the string to derive your codes from and encode. Build your Huffman tree from this string. The second line will consist of a test string of Os and 1s to decode. The input will terminate with a blank line. For example, emma dora ruth ziegellaub eichler Constraints When you initially add characters to your priority queue, break frequency ties alphabetically. Thereafter, when adding a new node to the priority queue, it should come after all nodes already on the queue with the same frequency Output Format The output will consist of two lines. The first line will be the encoding of the first input string according to your tree. The second line will be the decoding of the second input string according to your tree. For example, miriam ruth ziegellaub Implement a Huffman tree to encode and decode strings to and from variable-width encodings. Input Format The input will consist of two lines. The first line will be the string to derive your codes from and encode. Build your Huffman tree from this string. The second line will consist of a test string of Os and 1s to decode. The input will terminate with a blank line. For example, emma dora ruth ziegellaub eichler Constraints When you initially add characters to your priority queue, break frequency ties alphabetically. Thereafter, when adding a new node to the priority queue, it should come after all nodes already on the queue with the same frequency Output Format The output will consist of two lines. The first line will be the encoding of the first input string according to your tree. The second line will be the decoding of the second input string according to your tree. For example, miriam ruth ziegellaub

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago