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