Open the context
Choose the project folder and name the files or behavior involved.
Validate integer search-tree nodes with two child references. Check empty trees and ancestor bounds, returning false for duplicate keys while rejecting cycles, shared children, malformed nodes or over 1000 nodes.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def is_strict_bst(root):
pending, seen, checks = [(root, None, None)], set(), []
while pending:
node, low, high = pending.pop()
if node is None:
continue
if type(node) is not list or len(node) != 3 or type(node[0]) is not int:
raise ValueError("tree.node")
if id(node) in seen or len(seen) == 1000:
raise ValueError("tree.structure")
seen.add(id(node))
value, left, right = node
checks.append((value, low, high))
pending.extend([(right, value, high), (left, low, value)])
return all((low is None or low < value) and
(high is None or value < high) for value, low, high in checks)The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.