typedef struct word {
char *str;              /* Stores the word */
int freq;               /* Stores the frequency */
struct word *right;
struct word *left;
} Word;

Word *root = NULL;  //global variable

void * Insert(Word *node,Word *root)
        {
            //printf("inserted");
            if(root==NULL)
            {
                root = (Word *)malloc(sizeof(Word));
                root->str = (char*)malloc(strlen(node->str)+1);
                //printf("%s", node->str);
                strcpy(root->str,node->str);
                root->freq = node->freq;
                root->left = NULL;
                root->right = NULL;
            }
            else if (strcmp(node->str, root->str)==0){
                root -> freq = root->freq+1;
            }
            else if (strcmp(node->str, root->str)<1){
                Insert(node,root->left);
            }
            else {
                Insert(node,root->right);   
            }

            return 0;

        }

我正在尝试迭代结构的链接列表并将它们插入到BST中,这样我就可以按字母顺序输出字符串并进行顺序遍历 . 但是,当我调用我的inorder时,root始终为null,因此它不会迭代 . 我认为我的插入功能可能是错误的 . 我不确定我是否需要通过root操作并对其进行操作 . 有什么建议?