예제 #1
0
 // 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);
     }
 }
예제 #2
0
 public static void PrintInOrder()
 {
     BST.InOrderIterative(NextNodeProblem());
 }
예제 #3
0
 private static bool IsBst(BST tree)
 {
     return(IsBSTWrapper(tree, Int32.MinValue, Int32.MaxValue));
 }