I am doing huffman tree. the instruction is if you go from the left subtree, you have to add "0" if you go from the right subtree you have to add "1". I am trying to recursive function to add "0" or "1" to my string. I was just wondering if you can really do this with recursive function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
string HuffmanTree::add(BSTNode* current, char textchar)
{
string temp = " ";
string left = " ";
string right = " ";
if (current == NULL)
return" ";
left = add(current->left, textchar);
right = add(current->right, textchar);
if (current->data.frequency != textchar)
{
}
return"";
}
Hi Helios, I think I can do this iteratively, but I'm kind of wondering how would you implement it recursively. It been trying it for 3 days, I couldn't do it. Any hint would help