This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int is_binary_search_tree(struct node *n) { | |
| return is_bst(n, INT_MIN, INT_MAX); | |
| } | |
| int is_bst(struct node *n, int min, int max) { | |
| return !n || (n >= min && n < max) && is_bst(n->left, min, n->val) && is_bst(n->right, n->val, max); | |
| } |