public void DeleteOne(int xx) //删除单结点(递归) { //以左子树最大元素替换为例 Node <int> f = NoneRecurseNewSearch(xx); if (f == null) { Console.WriteLine("你要删除的结点不存在!"); return; } else if (f.IsLeaf()) { if (f.Parent.LeftChild == f) { f.Parent.LeftChild = null; } else { f.Parent.RightChild = null; } } else if (f.IsSingle()) { if (f.Parent.LeftChild == f) { if (f.LeftChild == null) { f.Parent.LeftChild = f.RightChild; } else { f.Parent.LeftChild = f.LeftChild; } } else { if (f.LeftChild == null) { f.Parent.RightChild = f.RightChild; } else { f.Parent.RightChild = f.LeftChild; } } } else { int x = FindPre(f).Data; DeleteOne(x); f.ChangeData(x); } FindParent(); }