You are viewing a single comment's thread. Return to all comments →
Here is my solution. But I dont really know where should I use the frequency or what it is for.
void decode_huff(node * root,string s) { node * curr; curr=root; for(int i=0;i<s.length();i++) { if(s[i]=='0') { curr=curr->left; if(curr->left==NULL||curr->right==NULL) { cout<<(curr->data); curr=root; } } if(s[i]=='1') { curr=curr->right; if(curr->left==NULL||curr->right==NULL) { cout<<(curr->data); curr=root; } } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
Here is my solution. But I dont really know where should I use the frequency or what it is for.