I am trying to write a function to delete a node any node from a binary search tree.
Binary Search Tree | Set 2 (Delete) - GeeksforGeeks
For some reason, the delete function deletes multiple nodes. It is a recursive function and I am somewhat confused when it comes to resursion. You need to move it past the next closing brace to place it after the else it's in:.
Additionally, the logic seems wrong for deleting the node when ID does match in that last else. What you need to do is either move the right branch to the rightmost node in the left branch, or the left branch to the leftmost node of the right branch So using your findMin to find the leftmost part of the right branch, we can do:.
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.
Log In Sign Up. Join the Stack Overflow Community. Stack Overflow is a community of 7.
Delete node from BST for C++ Code Example - Runnable
Join them; it only takes a minute: Deleting a node form a binary search tree in C Ask Question. You need to move it past the next closing brace to place it after the else it's in: So using your findMin to find the leftmost part of the right branch, we can do: Dmitri 6, 1 16 Sign up or log in StackExchange.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
Tree Removal Estimates | Local Landscaping Companies & Costs