Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. private HuffmanNode buildTree() {
  2.  
  3. PriorityQueue<HuffmanNode> pq = new PriorityQueue<>();
  4.  
  5. for(char i = 0; i < encodeTable.size(); i++) {
  6. pq.add(new HuffmanNode(i));
  7. }
  8.  
  9. while(pq.size() > 1) {
  10. HuffmanNode zero = pq.poll();
  11. HuffmanNode one = pq.poll();
  12. HuffmanNode parent = new HuffmanNode(zero.count + one.count);
  13. pq.add(parent);
  14. // System.out.println(pq);
  15.  
  16. }
  17. return pq.poll();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement