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

Removing the root node in binary_search_tree.py removes the whole tree. #8715

Closed
amirsoroush opened this issue May 8, 2023 · 0 comments · Fixed by #8752
Closed

Removing the root node in binary_search_tree.py removes the whole tree. #8715

amirsoroush opened this issue May 8, 2023 · 0 comments · Fixed by #8752
Labels

Comments

@amirsoroush
Copy link
Contributor

amirsoroush commented May 8, 2023

Repository commit

7310514

Python version (python --version)

Python 3.10.6

Dependencies version (pip freeze)

astroid==2.15.4
...

Expected behavior

https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/binary_search_tree.py

Removing the root node should not delete the whole tree, it should behave just like removing any other nodes. It works fine if we delete other nodes but I guess because of the this line, it has problem when we remove the root node. There should be other checks as well.

Actual behavior

>>> t = BinarySearchTree()
>>> t.insert(1)
>>> t.insert(2)
>>> t.insert(3)
>>> t.remove(1)
>>> str(t)
'None'
>>> 
@amirsoroush amirsoroush added the bug label May 8, 2023
yabea added a commit to yabea/Python that referenced this issue May 9, 2023
MandalAk pushed a commit to MandalAk/Python that referenced this issue May 16, 2023
@Frank-1998 Frank-1998 mentioned this issue May 20, 2023
14 tasks
Frank-1998 added a commit to Frank-1998/Python that referenced this issue May 20, 2023
cclauss pushed a commit that referenced this issue Jun 18, 2023
… tree (#8752)

* fix issue #8715

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this issue Sep 15, 2024
… tree (TheAlgorithms#8752)

* fix issue TheAlgorithms#8715

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant