public Map<Character,String> huffman(char[] input, int freq[]){
        HuffmanNodeComparator comparator = new HuffmanNodeComparator();
        PriorityQueue<HuffmanNode> heap = new PriorityQueue<HuffmanNode>(input.length,comparator);
        for(int i=0; i < input.length; i++){
            HuffmanNode node = new HuffmanNode();
            node.freq = freq[i];
            node.input = input[i];
            heap.offer(node);
        }
    
        while(heap.size() > 1){
            HuffmanNode node1 = heap.poll();
            HuffmanNode node2 = heap.poll();
            HuffmanNode node = new HuffmanNode();
            node.left = node1;
            node.right = node2;
            node.freq = node1.freq + node2.freq;
            heap.offer(node);
        }
        
        Map<Character,String> map = new HashMap<Character,String>();
        StringBuffer buff = new StringBuffer();
        createCode(heap.poll(),map,buff);
        return map;
        
    }
http://www.geeksforgeeks.org/greedy-algorithms-set-3-huffman-coding/
http://www.geeksforgeeks.org/greedy-algorithms-set-3-huffman-coding-set-2/
src/com/interview/tree/HuffmanEncoding.java