Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Business Management 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.

Business Management, Management Studies

  • Category:- Business Management
  • Reference No.:- M92532076
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Business Management

Discuss the importance of using an access control model in

Discuss the importance of using an access control model in determining how employees in an organization should gain access to resources.

Ellen is an anthropologist who has been working at olduvai

Ellen is an anthropologist who has been working at Olduvai Gorge in Tanzania for the past six months. She has been conducting research on the Internet. She finds a Web site with an article that proposes a revolutionary t ...

A firm has hired you as a consultant their only concern is

A firm has hired you as a consultant. Their only concern is to maximize profits. This firm is not in a perfectly competitive industry--they have some control over price. They give you the following information: We're sel ...

Design a moore machine where the output y goes high 1 when

Design a Moore machine where the output Y goes high (=1) when the last four bits of the input X were 1110: 4th to last bit seen = 1 3rd to last bit seen = 1 2nd to last bit seen = 1 Last bit seen = 0 Your machine must be ...

Suppose the total cost function for a firm is given by tc

Suppose the total cost function for a firm is given by: TC= 100 + 2q +0.5q2. Find the marginal cost function and then use that to determine the marginal cost of the 20th unit.

What goals seem to dominate early management principles why

What goals seem to dominate early management principles? Why do you think this is the case?

Consider yourself the senior manager of the irs tax exempt

Consider yourself the senior manager of the IRS Tax Exempt Organization when the situation described above occurred. Describe in detail how you would apply the Four Steps of Feedback Control to monitor and regulate the o ...

After reading the following article - select your favorite

After reading the following article - select your favorite product and prepare a step by step plan as to how you will engage your target consumer once you have the chance to personally try to sell him/her the product. Wh ...

What type of new jobs can the biotechnology market generate

What type of new jobs can the biotechnology market generate in India?

Very important assignmentthe alternative corporate growth

Very Important assignment The "Alternative Corporate Growth Strategies" grid, which I originally learned as the "Product Market Growth Matrix," is an excellent tool to learn. When companies experience a drop in sales in ...

  • 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