Skip to content
New issue

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

[内容有误] 二叉搜索树的一些方法的实现并不周详 #5344

Closed
1 task done
lingkerio opened this issue Jan 1, 2024 · 1 comment · Fixed by #5345
Closed
1 task done

[内容有误] 二叉搜索树的一些方法的实现并不周详 #5344

lingkerio opened this issue Jan 1, 2024 · 1 comment · Fixed by #5345
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed

Comments

@lingkerio
Copy link
Contributor

请选择:

  • 我正在着手修复这个问题

我正在访问这个页面

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);

@lingkerio lingkerio added Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed labels Jan 1, 2024
Copy link

welcome bot commented Jan 1, 2024

感谢你对 OI Wiki 的关注!记得在 Issue 中表达清楚自己的意思哦~

Tiphereth-A added a commit that referenced this issue Jan 5, 2024
* 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>
greenstripes4 pushed a commit to greenstripes4/OI-wiki that referenced this issue Jan 18, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant