public static void InOrderPrint(BinarySeachTree <T> parentNode) { if (parentNode == null) { return; } InOrderPrint(parentNode.Left); Console.WriteLine(parentNode.Value); InOrderPrint(parentNode.Right); }
public static BinarySeachTree <T> Insert(BinarySeachTree <T> parentNode, BinarySeachTree <T> newNode) { if (parentNode == null) { return(newNode); } if (Compare(newNode.Value, parentNode.Value) >= 0) { parentNode.Right = Insert(parentNode.Right, newNode); } else { parentNode.Left = Insert(parentNode.Left, newNode); } return(parentNode); }
public static BinarySeachTree <T> Search(BinarySeachTree <T> parentNode, BinarySeachTree <T> searchOperand) { if (parentNode == null) { return(null); } if (parentNode == searchOperand) { return(parentNode); } if (searchOperand >= parentNode) { return(Search(parentNode.Right, searchOperand)); } else { return(Search(parentNode.Left, searchOperand)); } }
public static BinarySeachTree <T> Search(BinarySeachTree <T> parentNode, T searchOperand) { return(Search(parentNode, new BinarySeachTree <T>(searchOperand))); }
public static BinarySeachTree <T> Insert(BinarySeachTree <T> parentNode, T value) { return(Insert(parentNode, new BinarySeachTree <T>(value))); }