I have an assignment on Huffman Coding to compresses and decompresses text document using Huffman code. I have created a Huffman tree where each Node contains BitArray with calculated Huffman code.
Main problem is encoding input file efficiently. I am not sure how to save encoded bytes(created by converting BitArray to byte array) without making collision between codes?
Example: There are two Huffman codes e = 101 and i = 0101. When they are converted to bytes they are represented as e = 00000101 and i = 00000101.
How can i avoid this and is there a better way to encode file?
What is the expected time for compressing and decompressing a file with 1 milion characters?
(For now i am creating a BitArray that contains all encoded bits and then convert it to byte[] and save it, witch is takes too much time and memory.)