We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
voiddecode_huff(node*root,strings){stringresult="";node*currNode=root;autoit=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;}elseif(*it=='1'){currNode=currNode->right;}else{cout<<"Error";}it++;}// Leaf. Get letter and reset.result+=currNode->data;currNode=root;}cout<<result;}
Cookie support is required to access HackerRank
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 →
C++