Question: Implement the check _ bst _ validity ( ) function in the BSTChecker.py file. The function takes the tree's root node as a parameter and

Implement the check_bst_validity() function in the BSTChecker.py file. The function takes the tree's root node as a parameter and returns the node that violates BST requirements, or None if the tree is a valid BST.
A violating node will be one of three things:
A node in the left subtree of an ancestor with a lesser key
A node in the right subtree of an ancestor with a greater key
A node with the left or right attribute referencing an ancestor
The given code in main.py reads and parses input, and builds the tree for you. Nodes are presented in the form (key, left_child, right_child), where left_child and right_child can be nested nodes or None. A leaf node is of the form (key). After parsing tree input, the check_bst_validity() function is called and the returned node's key (or "None") is printed.If the input is:
(50,(25, None, (60)),(75))
which corresponds to the tree above, then the output is:
60
because 60 violates BST requirements by being in the left subtree of 50.def check_bst_validity(root_node):don't change this function header. this must be in PYTHON
 Implement the check_bst_validity() function in the BSTChecker.py file. The function takes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!