COMPX301-24A —Assignment Two
LZW Compression
Due:Friday,26 April 2024 —3:00pm
Java代写 do not hesitate to contact me!
WeChat:lovexc60
Description:Implement LZW compression and decompression. This assignment is intended to be done in pairs(i.e.with a partner), but individual attempts are allowed.Use the General Discussion
Forum or contact your tutor if you want help finding a partner.Solutions are to be implemented in Java and must compile and run on the Linux machines in the R Block labs.
Specification:Implement the LZW compression and decompression routines according to the following specifications:
·We want to be able to compress any data(i.e.any stream of bytes),but we will design the
compressor and decompressor to work with data expressed as hexadecimal digits(i.e.nibbles).
So ..
·Write one program to convert an input stream of bytes into an output stream of hexadecimal
digits(as printable base-16 characters 0-F)and write another to convert such a stream of hex digits back into the corresponding stream of bytes,without loss of fidelity.Specifically:
o Write a program called ByteToHex.java that converts bytes to hexdigits
o Write a program called HexToByte.java that will take the output of your ByteToHex as
input and produce as output the exact input that had gone into your ByteToHex converter.
o You may use open source code to achieve this hex conversion and deconversion, or write
your own,but make sure you include proper citations to any borrowed code/algorithms/etc in the header of the code you submit(i.e.no plagiarism).
·Write a program called LZWencode that takes the output of ByteToHex and encodes it according to the LZW encoding algorithm described in lectures(i.e. a sequence of phrase numbers).
·Write a program called LZWdecode that takes the output of LZWencode and produces as output the exact input that had gone into LZWencode(i.e.write the complement decoder).
·Write a program called LZWpack that takes the output of LZWencode and outputs a stream of
bytes encoding the input in as few bits as are needed(i.e. log p bits per phrase number when there are p patterns in the dictionary).
·Write a program called LZWunpack that takes as input the output of LZWpack and produces as output the exact input that went into LZWpack
·A complete A+solution will have all programs,and an A solution can skip the bit packing and unpacking.
·The LZW encoder must utilise a multiway trie(not hashing)for the dictionary.
·Ideally,all input should be standard input and all output should be standard output so that the output from one program can be piped directly as input into the next one,simplifying
testing and marking,and making your code more flexible for use.But if you find standard
·Ma(in)e(u)tsure(an)dyou(ou)tnuctlude(too) ins on usa(you can)ge(u)sin(e)a REA(interim)D(f)ME(iles) .file(along with anything else you
want to communicate to the marker)so that there's no difficulty with using all your code.