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

  Debate surrounding globalization

Discuss the major points of the inequality between nations argument and describe how falling barriers to trade and investment might help reduce this inequality.

  Printing a triangle and the size of the peak for triangle

Allow the user to input two values: a character to be used for printing a triangle and the size of the peak for the triangle. Test the input for valid characters.

  Symbolic representation of machine instructions

2) A symbolic representation of machine instructions.

  Idea for future developments

Select a case study from the list provided by the teacher, analyse the case and research on the latest developments related to the case.

  Creates corresponding holes in the target file

creates corresponding holes in the target file.

  How would a user perceive the mouse motion

Suppose that mouse position changes are being sent over the connection. Assuming that multiple position changes are sent each RTT, how would a user perceive the mouse motion with and without the Nagle algorithm?

  Breaking into the mobile device market

Hasn't Intel had a problem with breaking into the mobile device market? Why is that? What might we attribute as the cause of the problem?

  An example of a picture effect for images in powerpoint 2007

An example of a picture effect for images in PowerPoint 2007 would be

  Draw the experimental region

Set up an experiment to fit a quadratic mixture model. Use n = 14 runs, with four replicates. Use the D-criterion.

  Why is it important to a systems developer

What are the most significant differences among structured, object-oriented, and agile methods? What do they have in common?

  What are the implications for a pal-based implementation

(Traffic Light Controller) The traffic light controller, as presented in Section 9.5, is a Mealy machine. Modify the description to make it part Moore/part Mealy by decoding the traffic-light control signals directly from the state, as we did in S..

  Weblogic server instance

What happens when a failure occurs and the stub cannot connect to a WebLogic Server instance?

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