设计判断一棵二叉树是否为二叉搜索树的算法
实在没什么思路,只是感觉,用递归会好点,求高手


bool isBST(struct tree *root) { if (root == NULL) return true; if (isBST(root->left) && isBST(root->right)) return (root->left == NULL ? true : (root->left->v < root->v)) && (root->right == NULL ? true : (root->v < root->right->v)); }