Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(weight: 30%) Programming: Write a function that tests whether a binary tree is

ID: 3709914 • Letter: #

Question

(weight: 30%) Programming: Write a function that tests whether a binary tree is a binary search tree. 4. Note: in a binary search tree, for each node, the values of all nodes in the right subtree are greater than the node, and the values of all nodes in the left subtree are less than the node. For instance, the following tree is not a binary search tree, because 15 must be less than 10. 10 7 12 6 15 513

Explanation / Answer

ANSWER:- IF tree is a binary search tree then function returns 1 and tree not a binary search tree function return 0 int isBST(struct node* node, int min, int max) { if (node==NULL) return 1; if (node->data data > max) return 0; return isBST(node->left, min, node->data - 1) && isBST(node->right, node->data + 1, max); }