Write a method is_binary_search_tree that returns true if a given tree is a BST (use helper function). — bool is_binary_search_tree(bst_node* node) { if (node == NULL) return true; return is_between(node, INT_MIN, INT_MAX); } bool is_between(bst_node* node, int min, int max) { if (node == NULL) return true; // ensure subtrees are not hiding a value lower or higher than the subtree // allows return node->value > min && node->value < max && is_between(node->left, min, node->value) && is_between(node->right, node->value, max); }
G
1.2K
Google Interview
This flashcard deck made by jwasham contains knowledge about google interview. For more details, please follow https://github.com/jwasham/google-interview-university