这个问题基本上说明了一切,但这是我到目前为止所拥有的
void inorder(Node *root)
{
int come_back_later=0;
if(come_back_later)
{
//part where i print out only the unique words from the tree
}
if(root==NULL)
return;
inorder(root->left);
cout<<root->word<<": it's word count is: "<< root->count<<endl;
inorder(root->right);
}
这个想法是我先进行中序遍历并打印出所有单词以及它们的计数。但是后来我想稍后重新访问该遍历并仅打印出唯一的单词,但我不知道如何为此创建算法代码。我所知道的,如果字数是 1,那么这个词必须是唯一的,因为它只在文件中出现过一次。如果有人可以帮助我,那就太好了。