Last active
April 22, 2018 17:32
-
-
Save DarioAle/797c5c079c19bbc499227ab258f7bc6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package huffmanTarea; | |
import java.io.IOException; | |
//import java.util.Arrays; | |
import java.util.Arrays; | |
import huffmanTarea.huffAlgorithm.Node; | |
import huffmanTarea.huffAlgorithm.priorityQueue; | |
public class TestHuffman { | |
public static void main(String args[]) throws IOException { | |
int[] frequencyArray = huffAlgorithm.countCharacters("test.txt"); | |
priorityQueue pq0 = huffAlgorithm.cretateQueue(frequencyArray); | |
priorityQueue pq1 = new priorityQueue(pq0.capacity); // you should create a copy of pq0 | |
pq1.size = 0; | |
for(int i = 0; i < pq0.capacity; i++) { | |
} | |
System.out.println(Arrays.toString(pq0.minHeap)); | |
//System.out.println(Arrays.toString(pq0.minHeap)); | |
Node root = huffAlgorithm.buildHuffman(pq0); | |
//Build huffman tree | |
//huffAlgorithm.print(root,0); | |
int r = 0; | |
int [][] map = new int[2][256]; | |
huffAlgorithm. encode(root, r, map,0); | |
String s = huffAlgorithm.writeOuput("test.txt", map,pq1); | |
System.out.println(s); | |
//read again document and create binary file | |
System.out.println(); | |
//System.out.println(Arrays.toString(a[0])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment