コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }