subject
Engineering, 24.04.2020 18:54 darcyshay62871

Run-length encoding (35 points). Data compression is used behind the scenes in computer systems quite often, computer files and other kinds of data can be compressed to a smaller size for easy storage or transportation. Later, they are decompressed and used in their original form. One basic idea is to find parts of the data that are identical to each other and use some kind of trick to describe that more efficiently. Run-length encoding (RLE) encodes a run of repetitions with the length of that run. 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. Replace each such sequence by a token consisting of: 1. the number of characters in the sequence 2. the repeating character If a 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: After applying the RLE algorithm, this string is converted into: q9w5e2rt5yqwzTST For example, consider the following string: After applying the RLE algorithm, this string is converted into: qw5e2rt5y4qw2Er3T In the compressed string, "9w represents a sequence of 9 consecutive lowercase "w characters. "5e" represents 5 consecutive lowercase "e" characters, etc Write a RLE library by implementing the following API: public class Run LengthEncoding /Encodes the original string by finding sequences in the string where the same character repeats Replace each such sequence by a token consisting of: the number of characters in the sequence followed by the repeating character. 1Write an iterative encode method 1Returns the encoded string. public static St ring encode (String original) /Decodes the original string encoded with the encode method. L Doturnc the decoded rina public class Run Lengt hEncoding 1/ Encodes the original string by finding sequences in the string /where the same character repeats 1 Replace each such sequence by a token consisting of: the number // of characters in the sequence followed by the repeating character. 1Write an iterative encode method // Returns the encoded string. public static String encode (String original) /Decodes the original string encoded with the encode method. 1/ Returns the decoded string. / YOUR decode METHOD MUST BE RECURSIVE. 1Do not use while, do/while, or for loops. public static String decode (String original) 1Tests each of the API methods by directly calling them. public static void main (Stringl] args) } For decode, you may assume that the character counts will be single-digit numbers (a character will not repeat more than 9 times consecutively). Hint # 1 : remember that characters are repeoontedkbymemmesie edes. You can For decode, you may assume that the character counts will be single-digit numbers (a character will not repeat more than 9 times consecutively). Hint #1 : remember that characters are represented by numeric codes. You can decrement a character variable as follows: char c = 7'; c-//c will now hold the character 6' Hint #2: You can check if a character is a digit by using the isDigit) method from the Character class as follows: char c 7' Character. isDigit (c) ; // returns true Hint #3: You probably will not need to use this hint for this problem. However, a fast way to convert a digit character into the numeric value of the digit is to subtract the character code for the digit zero: char c 7'; // this has the character code 55, not 7 int x c -'0'; // this produces the number 7 Observe the following rules: DO NOT use System. exit() DO NOT add the project or package statements. DO NOT change the class name. DO NOT change the headers of ANY of the given methods DO NOT add any new class fields. ONLY display the result as specified by the example for each problem DO NOT print other messages, follow the examples for each problem You may USE the StdOut library.

ansver
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 14:10, aliceohern
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
image
Engineering, 03.07.2019 14:10, bryneosburn
Line joining liquid phase with liquid and solid phase mixture is known as: a) liquidus b) solidus c) tie line d) none of the mentioned
Answers: 2
image
Engineering, 03.07.2019 19:30, 10040813
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
image
Engineering, 04.07.2019 19:10, pedropaulofpedrosapp
Tom is having a problem with his washing machine. he notices that the machine vibrates violently at a frequency of 1500 rpm due to an unknown rotating unbalance. the machine is mounted on 4 springs each having a stiffness of 10 kn/m. tom wishes to add an undamped vibration absorber attached by a spring under the machine the machine working frequency ranges between 800 rpm to 2000 rpm and its total mass while loaded is assumed to be 80 kg a) what should be the mass of the absorber added to the machine so that the natural frequency falls outside the working range? b) after a first trial of an absorber using a mass of 35 kg, the amplitude of the oscillation was found to be 10 cm. what is the value of the rotating unbalance? c) using me-3.5 kg. m, find the optimal absorber (by minimizing its mass). what would be the amplitude of the oscillation of the absorber?
Answers: 3
You know the right answer?
Run-length encoding (35 points). Data compression is used behind the scenes in computer systems quit...

Questions in other subjects:

Konu
Mathematics, 02.03.2021 19:40
Konu
Mathematics, 02.03.2021 19:40