Question: 3. Decompress Write your code in the file StringRec.java, your class must have this exact name with S and R capitalized Include a recursive method


3. Decompress Write your code in the file StringRec.java, your class must have this exact name with S and R capitalized Include a recursive method decompress with the following method header public static String decooress (String comressedText) The following restrictions apply to method decompress YOUR CODE MUST BE RECURSIVE Do not use loops (while do/while, or for Do not declare any variables outside of a method. You may declare local variables inside a method Method decompress will decompress text which has been compressed using the RLEalgorithm defined in the previous assignment and described below Run-length encoding (RLE) is a simple "compression algorithm" (an algorithm which takes a block of data and reduces its size, producing a block that contains the same information in less space). It works by replacing repetitive sequences ofidentical data items with short "tokens" that represent entire sequences. Applying RLE to a string involves finding sequences in the string where the same character repeats. Each such sequence should be replaced by a "token" consisting of 1 the number of characters in the sequence 2. the repeating character If a character does not repeat, it appears as a single character in the compressed string with no number preceding it For example, consider the following string WwwwwwwwweeeeerrtyyYy9wErrrt After applying the RLE algorithm, this string is converted into: In the compressed string. "9represents a sequence of 9 consecutive lowercase 'w characters. "5e represents 5 consecutive lowercase "e characters, etc For example, the following call to decompress decompress ("ggw5e2rt5y4qw2Rr3T) returns the string: qwwwwwwwwweeeeerrtwwwaqqqWEErITT You may write your own main method to test your decompress method. Autolab will ignore your main method For this problem, yo may assume that the character counts will be single-digit numbers (a character will not repeat more than 9 times consecutively) Hint #1 remember that characters are represented by numeric codes. You can decrement a character variable as follows. char c / will now hold the character 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
