Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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 public statie String The following restrictions apply to method decompress: YOUR CODE MUST BE RECURSIVE Do not use loops (while, donwhile, orfor). 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 RLE algorithm 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 the number of characters in the sequence the repeating character fa 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 fter applying the RIE algorithm, this string is converted into In the compressed string. "represents a seguence of 9 consecutive lowercase "w" characers, "Se represents 5 consecutive lowercase "e" characters, etc. For example, the following call to decompress decompress9we2rn5y4qw2Er3T") returns the string may write your own main method to test y method. Autolab will ignore your main method For this problem, you may assume that the character counts will be single-digit mumbers (a character will not repeat more than 9 times consecutively). Hintremember that characters are represented by numeric codes. You can decrement a character variable as follows: char 7 c-- will now hold the character '6 Hint #2: You probably will not need to use this hint for this problem. However a Jast way to convert a digit character into the mumeric value of the digit is to subtract the character code for the digit zero: char -7 intx c- // this has the character code 55, not 7 I/ this produces the number 7

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

5-4 What are the current computer software platforms and trends?

Answered: 1 week ago