Function to find is a binary tree is a binary search tree.
(node, lower_lim=None, upper_lim=None)
| 145 | |
| 146 | |
| 147 | def is_bst(node, lower_lim=None, upper_lim=None): |
| 148 | """Function to find is a binary tree is a binary search tree.""" |
| 149 | if lower_lim is not None and node.info < lower_lim: |
| 150 | return False |
| 151 | if upper_lim is not None and node.info > upper_lim: |
| 152 | return False |
| 153 | is_left_bst = True |
| 154 | is_right_bst = True |
| 155 | if node.left is not None: |
| 156 | is_left_bst = is_bst(node.left, lower_lim, node.info) |
| 157 | if is_left_bst and node.right is not None: |
| 158 | is_right_bst = is_bst(node.right, node.info, upper_lim) |
| 159 | return is_left_bst and is_right_bst |
| 160 | |
| 161 | |
| 162 | def postorder(node): |
nothing calls this directly
no outgoing calls
no test coverage detected