Start by clarifying the definition of a BST and edge cases, then propose an in-order traversal approach that checks if the sequence is strictly increasing. Alternatively, use a recursive approach with min/max bounds to validate each node, discussing trade-offs between time and space complexity.
Pro tip: Mention that using in-order traversal with a single previous pointer is elegant and uses O(1) extra space if you do Morris traversal, but be prepared to discuss recursion stack space. Also, emphasize that duplicates are typically not allowed in a BST, so use strict inequality.
Ask if the tree can contain duplicates and confirm that a BST requires left < root < right. Also, discuss edge cases like empty tree or single node.
Decide between in-order traversal (checking for sorted order) or recursive min/max bounds. Explain why in-order is simpler and more efficient.
Write clean code for the chosen approach. For in-order, use a recursive or iterative traversal and keep track of the previous node's value.
State that time complexity is O(n) since each node is visited once, and space complexity is O(h) for recursion stack (or O(1) with Morris traversal).
Walk through a few test cases: valid BST, invalid BST, tree with duplicates, and edge cases like skewed tree.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.