// Wrong implementation of IsBST public static bool Isit(BST tree) { if (tree == null) { return(false); } else { if (tree.left != null && tree.left.data > tree.data) { return(false); } if (tree.right != null && tree.right.data < tree.data) { return(false); } if (!Isit(tree.left) || !Isit(tree.right)) { return(false); } return(true); } }
public static void PrintInOrder() { BST.InOrderIterative(NextNodeProblem()); }
private static bool IsBst(BST tree) { return(IsBSTWrapper(tree, Int32.MinValue, Int32.MaxValue)); }