Question
Java Run Length Encoding (RLE): RLE is a very simple form of lossless data compression technique in which a stream of data is given as
Run Length Encoding (RLE): RLE is a very simple form of lossless data compression technique in which a stream of data is given as the input and the output is a sequence of counts of consecutive data values in a row. RLE is lossless as when decompressed, all the original data will be recovered when decoded. Its simplicity in both encoding (compression) and decoding (decompression) is one of the most attractive features of the algorithm. Example of RLE: Input: w->w->w->w->a->a->a->d->e->x->x->x->x->x->x Encoded (Compressed) String: 4w3a1d1e6x Encoded String: 3a1b3c3d2a Decoded Output: a->a->a->b->c->c->c->d->d->d->a->a
Implement the RLE class that includes the following operations: o encode(): takes the SLL as the parameter & prints the encoded string as seen in the example above. o decode(): takes the encoded string as the parameter and prints the decoded SLL as seen in the example above. o equal(): takes 2 SLL as parameters and returns true if they represent the same sequence and false if they are not the same. Input: Your program will accept an input file (see input.txt) with 3 test cases in the following format: o Test 1: Input for Encoding Input 1 Input 2 Input 3 o Test 2: Input for Decoding Input 1 Input 2 Input 3 o Test 3: Input for equality Input 1 Input 2 Input 3 Input 4 Your input will be in a String format, so your driver program should be able to convert the input String to a SLL. Output: Your program will generate an output file (output.txt) that includes output for all 3 test cases & some analysis in the following format: o Test 1: Output for Encoding [Input SLL: uncompressed bits] [Encoded String: compressed bits] [compression ratio] Example: [w->w->w->w->a->a->a->d->e->x->x->x->x->x->x:15] [4w3a1d1e6x:10] [1.5] o Test 2: Output for Decoding [Encoded String] [Decoded SLL] Example: [3a1b3c3d2a][a->a->a->b->c->c->c->d->d->d->a->a] o Test 3: Output for equality [SLL1][SLL2][equality] Example: [3a1b][2a1a1b][true]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started