Link to home
Start Free TrialLog in
Avatar of perdoname_
perdoname_

asked on

Pointer to 500 points! q: About an encoder

Link to the 1st thread:
https://www.experts-exchange.com/questions/23122949/Encoder-Java.html

Instructions:
"write a program that compresses les so that they are
as small as possible and decompress to exactly the original le. How the compression program works is
completely up to you. Note that all numbers are written in hexidecimal notation as it makes bit patterns
easier to see. "

specs:

The decompressor is quite simple, it has a dictionary of 0xFF (that is, 255) phrases. The zeroth phrase is a byte with value 0x0, the first phrase is a byte with value 0x1 and so on, (the nth element of the array is a
phrase consisting of a bytse with value n). The decompressor reads the input one byte at a time and treats
each one as an instruction:
0xFF Set N equal to the next byte of the input and output N (called an escape action)
0xFE Set N equal to the next byte of the input and output the Nth phrase in the dictionary (called a look
up action)
0xFD Do nothing
...
0xF0 Do nothing
0xEF Repeat the next instruction 0xF (that is 15) times
0xEE Repeat the next instruction 0xE (that is 14) times
...
0xE2 Repeat the next instruction 2 times
0xE1 Repeat the next instruction 1 time (these are called repeat actions)
0xE0 Do nothing
0xDF Set N equal to the next byte of the input and set the Nth phrase in the dictionary equal to the next
0xF instructions 0xDE - Set N equal to the next byte of the input and set the Nth phrase in the
dictionary equal to the next 0xE instructions
...
0xD2 Set N equal to the next byte of the input and set the Nth phrase in the dictionary equal to the next
0x2 instructions
0xD1 Set N equal to the next byte of the input and set the Nth phrase in the dictionary equal to the next
instruction (these are called define actions)
0xD0 Do nothing
0xCF Output the 0xCFth phrase in the dictionary
0xCE Output the 0xCFth phrase in the dictionary
...
0x02 Output the 0x2nd (second) phrase in the dictionary
0x01 Output the 0x1nd (first) phrase in the dictionary
0x00 Output the 0x0th (zeroth) phrase in the dictionary
ASKER CERTIFIED SOLUTION
Avatar of sciuriware
sciuriware

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial