Question: Using Java, encode a paragraph into a string of binary numbers based on the frequency of characters. The most common characters should be given the
Using Java, encode a paragraph into a string of binary numbers based on the frequency of characters. The most common characters should be given the lowest binary value. If there are multiple characters with the same frequency, select the first alphabetically to have the smaller value.
Data structures that can be used are limited to arrays, maps, graphs, trees, lists, tables, heaps, stacks, and queues.
All methods must include bigO runtimes and the program itself should run in O(N).
For example:
"Hello, World" --> 111 101 0 0 1 1000 10 110 1 11 0 100
"The quick brown fox jumps over the lazy dog" --> 110 11 10 0 10100 101 1101 1001 1111 0 1000 100 1 11000 10010 0 1011 1 11001 0 1110 101 10001 10011 10101 0 1 10111 10 100 0 10110 11 10 0 10000 111 11011 11010 0 1010 1 1100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
