BETA

Difficulty Level: Easy

Submissions: 31 Accuracy:

54.84%

Huffman Decoding (Function Problem)
       

Given a binary encoded string and a Huffman MinHeap tree, your task is to complete the function decodeHuffmanData(), which decodes the binary encoded string and return the original string. 


Example:

Input Data : AAAAAABCCCCCCDDEEEEE
Frequencies : A: 6, B: 1, C: 6, D: 2, E: 5
Encoded Data : 
0000000000001100101010101011111111010101010
Huffman Tree: '#' is the special character used for 
               internal nodes as character field is 
               not needed for internal nodes. 
               #(20)
             /       \
        #(12)         #(8)
     /      \        /     \
    A(6)     C(6) E(5)     #(3)
                         /     \
                       B(1)    D(2)  
Code of 'A' is '00', code of 'C' is '01', ..
Decoded Data : AAAAAABCCCCCCDDEEEEE

Input:
The function takes two arguments as input, the reference pointer to the root of the Huffman minheap tree and an binary encoded string.
There will be T test cases and for each test case the function will be called separately.

Note: Input test cases contains English alphabetical string of size N, that will be encoded using Huffman Encoding and the encoded string will be provided to you.

Output:
For each test case print the decoded string from the provided encoded string.

Constraints:
1<=T<=200
1<=N<=103

Example:
Input:

2
01110100011111000101101011101000111
1011010011100101101110111
Output:
geeksforgeeks
India

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

** For More Input/Output Examples Use 'Expected Output' option **


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.