Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: SOLVE WITHOUT HASHMAP (JAVA) ENCODER SOLVE WITHOUT HASHMAP (JAVA) ENCODER Run length encoding is a simple form of data compression. It replaces long sequences

Question: SOLVE WITHOUT HASHMAP (JAVA) ENCODER

SOLVE WITHOUT HASHMAP (JAVA) ENCODER

Run length encoding is a simple form of data compression. It replaces long sequences of a repeated value with one occurrence of the value and a count of how many times to repeat it. This works reasonably well when there are lots of long repeats such as in black and white images. To avoid having to represent non-repeated runs with a count of 1 and the value, a special value is often used to indicate a run and everything else is just treated as a simple value. For this exercise you will compress one line of input at at time according to the following: The newline characters are passed through uncompressed even when there are repeated blank lines. When a run of n>=3 repeated characters, c, is detected where c is NOT a digit, the run will be replaced with #nc.

When a run of n>=3 repeated characters, c, is detected where c IS a digit, the run will be replaced with #n#c. The extra # is needed to avoid confusing the repeated digit c with the last digit of the run count. All other characters (i.e. runs of just 1 or 2 characters) are passed through unmodified. Assume the input does not contain the symbol '#'.This assumption can be eliminated. You might think about how you would do it.

Some examples: abc compresses to abc

aaabcccc compresses to #3ab#4c

abc1233333333333333 compresses to abc12#14#3

aabbcc xyzzz 123

compresses to #2a#2b#2c - MULTIPLE LINES OF INPUT xy#3z 123

Your encoder must include a public static method compress() that takes one parameter, a String, that is the line to be compressed. The method returns the compressed String. DO NOT USE A HASHMAP!

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

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions