subject

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: the number of characters in the sequence 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: q9w5e2rt5y4qw2Er3T 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 RunLengthEncoding { // 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. // Write an iterative encode method. // Returns the encoded string. public static String encode (String original) // Decodes the original string encoded with the encode method. // Returns the decoded string. // YOUR decode METHOD MUST BE RECURSIVE. // Do not use while, do/while, or for loops. public static String decode (String original) // Tests each of the API methods by directly calling them. public static void main (String[] args) } // Tests each of the API methods by directly calling them. public static void main (String[] 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 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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
question
Computers and Technology, 23.06.2019 01:00
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan.in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan.out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
You know the right answer?
Run-length encoding (35 points). Data compression is used behind the scenes in computer systems quit...
Questions
question
Mathematics, 30.03.2020 19:09
question
Mathematics, 30.03.2020 19:09
question
Mathematics, 30.03.2020 19:10
Questions on the website: 13722361