Question: One obvious way to compress binary data is to count the 0s and 1s, and to represent sequences of one digit as a single number.

One obvious way to compress binary data is to count the 0s and 1s, and to represent sequences of one digit as a single number. Thus a String sequence like "00100111" would be compressed to "2, 1, 2, 3". The first number in the compressed sequence is always the number of initial 0s, so a sequence like "1101111" would be compressed to "0, 2, 1, 4". a) Write the method compress that takes a String s containing only 0s and 1s, and returns a compressed version of s.//returns a compressed version of s public static String compress (String s) b) Write the method uncompress that takes a String s containing only digits, and returns an uncompressed version of s.//returns an uncompressed version of s public static String uncompress (String s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
