我正在二叉搜索树的有序遍历中搜索数据的位置(索引号)。
void inorder(struct node *root) {
if(!root)
return NULL;
inorder(root->left);
cout<<root->data;
inorder(root->right);
}
我如何修改此函数以获取给定数字的位置。
我正在二叉搜索树的有序遍历中搜索数据的位置(索引号)。
void inorder(struct node *root) {
if(!root)
return NULL;
inorder(root->left);
cout<<root->data;
inorder(root->right);
}
我如何修改此函数以获取给定数字的位置。