Binary search tree delete node function
My delete function doesn't work when I try to delete node with only right child. It works when node has left child only or has both left and right. I would like to know if this is a valid approach to this problem. I know how to write this in C++ but I need it to work in C# also. //Private method, with args: root node, node to be deleted private Node DeleteN(Node root, Node deleteNode) { if (root == null) { return root; } if (deleteNode.data < root.data) { root.left = DeleteN(root.left, deleteNode); } if (deleteNode.data > root.data) { root.right = DeleteN(root.right, deleteNode); } if (deleteN
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.