Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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