public void Postorder(Bnode Root) { if (Root != null) { Postorder(Root.Left); Postorder(Root.Right); Console.Write(Root.Value + " "); } }
public bool Insert(object data) { Bnode NewNode = new Bnode() { Value = data }; Bnode TempParent; if (Root.Value == null) { Root = NewNode; return(true); } else { Current = Root; while (true) { TempParent = Current; if (Convert.ToInt32(NewNode.Value) < Convert.ToInt32(Current.Value)) { Current = Current.Left; if (Current == null) { TempParent.Left = NewNode; return(true); } } else { Current = Current.Right; if (Current == null) { TempParent.Right = NewNode; return(true); } } } } return(false); }
public BinarySTree() { Root = new Bnode(); Current = Root; }
public Bnode() { Right = Left = null; }