Method with the signature

Assignment Help Basic Computer Science
Reference no: EM131725502

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.

Reference no: EM131725502

Questions Cloud

Create a measurable null and alternative hypothesis : Create a measurable null and alternative hypothesis - Identify the number of samples, whether they are independent, and what type of data will be collected
Despite the large volume of notes written about telnet : Despite the large volume of notes written about TELNET, it can be argued that the protocol is still not well-defined.
Employers are finding health insurance coverage : Employers are finding health insurance coverage more difficult to support as a benefit because it has become more costly than the tax savings for offering it.
Calculate annual product cost and average cycle stock : Calculate annual product cost. Calculate average cycle stock. Calculate average inventory.
Method with the signature : 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.
Discuss about the communication protocols : Folklore says that operating systems come and go while protocols last forever. Test this axiom by surveying your local computing site to see whether operating.
Systematically aids in identifying : A resource-based view of a firm provides a model that systematically aids in identifying
Apply tracert command on windows : Apply tracert command on Windows to 74.125.21.100. Report the result, including screenshot or copy/paste your traceroute output.
Using the mean absolute deviation for forecasts : Using the Mean Absolute Deviation for forecasts for May through July, explain which of these methods is likely to produce the most accurate forecast for August.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Give a cfg for the set of all strings

Give a CFG for the set of all strings over {a,b} with twice as many a's as b's

  Focus of the final paper

This paper will demonstrate your understanding of the key concepts at the core of good project management practices covered throughout this course. Your paper should be based on a project (either theoretical or an actual project) and how issues of ma..

  Why is data privacy a concern in the e-commerce environment

What is different about data security concerns in the Internet environment vs. the non-Internet environment?

  What tensile force does the cable have to support

Assuming the cable can only support a tensile force, would you connect it to the right or left side? What tensile force does the cable have to support? Assume the flow to be frictionless.

  What is its steady-state temperature

If the surface emissivity is 1.0 and the surface is not exposed to the sun, what is its steady-state temperature? If the surface is exposed to a solar flux of , and its absorptivity to solar radiation is 0.25, what is its steady-state temperature?

  Design a circuit that finds the most significant non-zero

The circuit should produce not only the shifted binary number but also a binary representation of the amount of the shift.

  Find and prove matching upper and lower bounds

You can place objects on each side of the scale and see which collection is heavier. Your goal is to find the heavier object, with the minimum number of weighings. Find and prove matching upper and lower bounds for this problem.

  What is the size of the working-age population

Suppose the stock of capital and the workforce are both increasing at 3 percent annually in the country of Wholand. At the same time, real output is growing at 6 percent. How is that possible in the short run and in the long run?

  Display a message that the magazine will be sent

display a message that the magazine will be sent.

  Write a program that encrypts a text by applying xor

Write a program that encrypts a text by applying XOR (excluding or) operation between the given source characters and given cipher code.

  Rewrite the shape hierarchy to store the area

Rewrite the Shape hierarchy to store the area as a data member and have it computed by the constructor. Make area a nonvirtual function that returns.

  Title-intellectual property

Intellectual property is a term used to describe works of the mind, such as art, books, films, formulas, inventions, music, and processes

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd