Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write code in the file Compress.java. The code should go into a method with the following signature. May own main method to test your code. The graders will ignore the main method:

public static String compress (String original){}

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 of identical 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 should be left alone.

For example, consider the following string:

qwwwwwwwwweeeeerrtyyyyyqqqqwEErTTT

After applying the RLE algorithm, this string is converted into:

q9w5e2rt5y4qw2Er3T

In the compressed string, "9w" represents a sequence of 9 consecutive lowercase "w" characters. "5e" represents 5 consecutive lowercase "e" characters, etc.

Need a method called compress that takes a string as input, compresses it using RLE, and returns the compressed string. Case matters - uppercase and lowercase characters should be considered distinct. You may assume that there are no digit characters in the input string. There are no other restrictions on the input - it may contain spaces or punctuation. There is no need to treat non-letter characters any differently from letters.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92534190
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Task 1 use the sumofnnumbersjava file create a method that

Task 1: Use the sumOf_N_Numbers.java file. Create a method that takes in two parameters namely the starting and ending number of the range and returns the sum of all the numbers in that range to the calling method Task 2 ...

The sales figures for a business are as follows for the

The sales figures for a business are as follows for the first six months of the year: R40 000, R44 000, R52 000, R64 000, R80 000, R84 000. The owner believes that the sales curve can be approximated by a quadratic funct ...

Should we be renegotiating nafta yes or no if it is

Should we be renegotiating NAFTA? yes or no? If it is renegotiated, should it be replaced? What reasons would make it better in your point of view? What is the best argument you can make why NAFTA should or should not be ...

Explain the differences between working in the web based

Explain the differences between working in the web based version of Outlook in Office 365 to the desktop application version of Outlook.

Question using the apple company identify all the social

Question: Using the Apple company, identify all the social media platforms it currently uses. List all the social media platforms. List five different KPI's you could use to measure the engagement on each platform. Expla ...

A chemistry student needsnbsp700 g of ethanolamine for an

A chemistry student needs 70.0 g of ethanolamine for an experiment. By consulting the  CRC Handbook of Chemistry and Physics , the student discovers that the density of ethanolamine is 1.02 g.cm^-3. Calculate the volume ...

Discuss 5 of the most important sql server management

Discuss 5 of the most important SQL Server Management Studio (SSMS) features. Provide references - website link, book, article, etc.

Patient patientid familyname givenname address suburb state

PATIENT (PatientID, FamilyName, GivenName, Address, Suburb, State, PostCode) DOCTOR (ProviderNo, Name) ITEM (ItemNo, Description, Fee) ACCOUNT (AccountNo, ProviderNo, PatientID, TreatmentDate) ACCOUNTLINE (AccountNo, Ite ...

Consider the market for small business loans in the context

Consider the market for small business loans. In the context of this market. How adverse selection impact lenders. How does adverse selection impact borrowers? In the context of this market provide 2 things that a lender ...

Suppose you are doing some online banking using your banks

Suppose you are doing some online banking using your bank's website. An attacker has set up an active wiretap between your computer and your bank's server. After checking your balance and reading through your transaction ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As