-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHuffman.java
47 lines (43 loc) · 1.66 KB
/
Huffman.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.IOException;
/**
* You must need to implement this interface for any credit.
* Please do not modify this file
*/
public interface Huffman {
/**
* Encodes the input file using Huffman Coding. Produces two files
*
* @param inputFile The name of the input file to be encoded.
* Do not modify this file.
*
* @param outputFile The name of the output file (after encoding)
* This would be a binary file.
* If the file already exists, overwrite it.
*
* @param freqFile Stores the frequency of each byte
* This file is a text file
* where each row contains texual representation
* of each byte and the number of occurence of this byte
* separated by ':'
* An example entry would look like:
* 01100001:12345
* Which means
* the letter a (ascii code 097, binary representation 01100001)
* has occureed 12345. This file does not need to be sorted.
* If this file already exists, overwrite.
* */
public void encode(String inputFile, String outputFile, String freqFile);
/**
* Decodes the input file (which is the output of encoding())
* using Huffman decoding.
*
* @param inputFile The name of the input file to be decoded.
* Do not modify this file.
*
* @param outputFile The name of the output file (after decoding)
*
* @param freqFile freqFile produced after encoding.
* Do not modify this file.
* */
public void decode(String inputFile, String outputFile, String freqFile) throws IOException;
}