【发布时间】:2015-05-01 04:35:23
【问题描述】:
这个问题基本上说明了一切,但这就是我目前所知道的
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,那么这个词必须是唯一的,因为它只在文件中出现过一次。如果有人可以帮助我,那就太好了。
【问题讨论】:
标签: binary-tree unique traversal inorder