isValidBST · DFS vs BFS traced step by step

Both algorithms use the same invariant: every node must sit strictly inside the open window (minVal, maxVal) handed down by its ancestors — a node's value becomes maxVal for its left subtree, minVal for its right subtree. Only the order in which nodes are visited changes.

presets:
amber = being explored (DFS path / BFS current) blue = waiting in the queue (BFS) in window window violated label under a node = its (minVal, maxVal)