We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://oi-wiki.org/ds/bst
以致insert函数中当root为nullptr时new的节点的count和size都是0,和其他函数的语义不匹配。
在return queryRank(root->right, v) +(root->left ? root->left->size + root->count : 0);和return querykth(root->right,k - (root->left ? root->left->size + root->count : 0));中,左子树不存在时也应该加上当前节点的count/减去当前节点的count,故应该修改为return queryRank(root->right, v) + (root->left ? root->left->size : 0) + root->count;和return querykth(root->right, k - (root->left ? root->left->size : 0) - root->count);
return queryRank(root->right, v) +(root->left ? root->left->size + root->count : 0);
return querykth(root->right,k - (root->left ? root->left->size + root->count : 0));
return queryRank(root->right, v) + (root->left ? root->left->size : 0) + root->count;
return querykth(root->right, k - (root->left ? root->left->size : 0) - root->count);
The text was updated successfully, but these errors were encountered:
感谢你对 OI Wiki 的关注!记得在 Issue 中表达清楚自己的意思哦~
Sorry, something went wrong.
fix(docs/ds/bst.md): 二叉搜索树的一些方法的实现并不周详 (#5344) (#5345)
e8a4f74
* Update bst.md 更新了二叉搜索树节点定义与几个函数 * Update bst.md * style: format markdown files with remark-lint * Update bst.md * style: format markdown files with remark-lint * fix(bst.md): indent * style: format markdown files with remark-lint * fix(bst.md): indent * style: format markdown files with remark-lint --------- Co-authored-by: 24OI-bot <15963390+24OI-bot@users.noreply.github.com> Co-authored-by: Tifa <62847935+Tiphereth-A@users.noreply.github.com>
fix(docs/ds/bst.md): 二叉搜索树的一些方法的实现并不周详 (OI-wiki#5344) (OI-wiki#5345)
3bfb0bd
Successfully merging a pull request may close this issue.
请选择:
我正在访问这个页面
https://oi-wiki.org/ds/bst
我发现页面有这样的问题
没有给size和count设置默认值1
以致insert函数中当root为nullptr时new的节点的count和size都是0,和其他函数的语义不匹配。
queryRank和querykth函数在右子树查找时对当前节点的重复次数的考虑错误
在
return queryRank(root->right, v) +(root->left ? root->left->size + root->count : 0);
和return querykth(root->right,k - (root->left ? root->left->size + root->count : 0));
中,左子树不存在时也应该加上当前节点的count/减去当前节点的count,故应该修改为return queryRank(root->right, v) + (root->left ? root->left->size : 0) + root->count;
和return querykth(root->right, k - (root->left ? root->left->size : 0) - root->count);
The text was updated successfully, but these errors were encountered: