// удалить из дерева корень root узел со значением data public void DeleteNode(int data) { TreeNode node = FindNode(root, data); if (node == null) { return; } TreeNode left = node.left; TreeNode right = node.right; TreeNode parent = node.parent; if (right == null) { if (parent != null) { parent.replaceChild(node, left); } else { root = left; } return; } if (parent != null) { parent.replaceChild(node, right); } else { root = right; } if (left == null) { return; } TreeNode leastRightLeft = findMinNode(right); leastRightLeft.left = left; }