Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6vDJ5fWY5uEZaJFNi
25 lines
664 B
Plaintext
25 lines
664 B
Plaintext
Validate BST: the children-only check, the bounds check, the sentinel trap
|
|
==========================================================================
|
|
|
|
A tree where 55 sits in the LEFT subtree of 50:
|
|
50
|
|
L: 30
|
|
L: 20
|
|
R: 55
|
|
R: 70
|
|
L: 60
|
|
R: 80
|
|
|
|
childrenOnly: true
|
|
isBst: false
|
|
byInorder: false inorder = [20, 30, 55, 50, 60, 70, 80]
|
|
|
|
Bounds trace (stops at the first violation):
|
|
node 50 allowed (-inf, +inf) ok
|
|
node 30 allowed (-inf, 50) ok
|
|
node 20 allowed (-inf, 30) ok
|
|
node 55 allowed (30, 50) VIOLATION
|
|
|
|
single node 2147483647: intSentinels=false isBst=true
|
|
single node -2147483648: intSentinels=false isBst=true
|