Tree: Huffman Decoding

Sort by

recency

|

20 Discussions

|

  • + 0 comments

    Test project is not valid as it is not giving encoded string so you have to write encoding + decoding all together

  • + 0 comments

    C++

    void decode_huff(node * root, string s) 
    {
        string result = "";
        node * currNode = root;
        auto it = s.begin();
        
        while (it != s.end())
        {
            // Read s and traverse until we reach a leaf.
            while (currNode->data == '\0')
            {
                if (*it == '0')
                {
                    currNode = currNode->left;
                }
                else if (*it == '1')
                {
                    currNode = currNode->right;
                }
                else 
                {
                    cout << "Error";
                }
                
                it++;
            }
            
            // Leaf. Get letter and reset.
            result += currNode->data;
            currNode = root;
        }
        
        cout << result;
    }
    
  • + 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); }