public static bool IsBST(TreeBinaryNode <int> tree) { Traversal <int> t = new Traversal <int>(TypeTraversal.inOrder, tree); List <int> inOrderList = t.getTraversalList(); return(inOrderList.Zip(inOrderList.Skip(1)).All(l => l.First < l.Second)); }
public static bool isBST(TreeBinaryNode <int> tree) { Traversal <int> t = new Traversal <int>(TypeTraversal.inOrder, tree); List <int> inOrderList = t.getTraversalList(); for (int i = 0; i < inOrderList.Count - 1; i++) { if (inOrderList[i + 1] <= inOrderList[i]) { return(false); } } return(true); }