Tree: Huffman Decoding

Sort by

recency

|

18 Discussions

|

  • + 0 comments

    Here is Hackerrank Tree huffman decoding problem solution in Python Java c++ c and javascript

  • + 0 comments

    There is something wrong with the problem as my solution just return the same input and it will work javascript

    function processData(input) {
        //Enter your code here
        console.log(input);
    } 
    
  • + 0 comments

    There is something wrong with the problem as my solution just return the same input and it will work javascript function processData(input) { //Enter your code here console.log(input); }

  • + 0 comments

    JAVA

    void decode(String s, Node root) {        
        Node current = root;
        for (char c : s.toCharArray()) {           
            if (c == '0') {
                current = current.left;
            } else {
                current = current.right;
            }
            
            if (current != null && current.data != '\0') {
                System.out.print(current.data);
                current = root;
            }
            
        }
    }
    
  • + 0 comments
    def decodeHuff(root, s):
        curr_node = root
        for bit in s:
            if bit == '1':
                curr_node = curr_node.right
            elif bit == '0':
                curr_node = curr_node.left
            if not curr_node.right and not curr_node.left:
                print(curr_node.data, end='')
                curr_node = root