代写C++代码 代做C++程序 C++辅导 C++教学

C++网络家教 远程写代码 在线Debug 讲解答疑 不是中介,本人直接写

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

In a namespace called Lab5, write C# classes called RootedBinaryTree and Compressor using the supplied code stub.


The huffman method should accept an array of Word objects with the plainWord and probability fields filled in, and return the same array with the codeWord fields also filled in according to Huffman's Algorithm. In implementing Huffman's Algorithm, make use of the RootedBinaryTree class. Note that RootedBinaryTree should perform shallow copying to reduce the time- and space-complexity of tree operations.


The compress method of the Compressor class should read the given input file from disk, assign probabilities to characters according to their frequency of occurrence in the file, use the huffman method to translate the characters into codewords, and finally write the output file in binary format as the sequence of codewords of the input file, character by character.


OPTIONAL: At the beginning of the output file in the compress method, write a dictionary of character/codeword pairs in a fixed-length format, as follows: n+b1+L1+c1+b2+L2+c2+...+bn+Ln+cn, where: n is a 1-byte number indicating how many character/codeword pairs will follow; b1, b2, ..., bn are 1-byte ASCII character values; L1, L2, ..., Ln are 1-byte values of the lengths (in bits) of the codewords; and c1, c2, ..., cn are the codewords associated with b1, b2, ..., bn, respectively. Then complete the decompress method of the Compressor class.


相关推荐