My first instinct was to just do an inorder traversal and run a standard LIS on the result, which would've been wrong because inorder on a BST already gives you sorted values and that's not the same as preserving node order.
Clarify that the problem reduces to finding the longest increasing subsequence (LIS) of the node values in the order they appear in a traversal of the BST. Choose an appropriate traversal (e.g., preorder) to preserve the original node order, then apply an O(n log n) LIS algorithm. Discuss time/space complexity and potential optimizations.
Pro tip: Mention that while a BST's inorder traversal yields sorted order, the problem explicitly requires preserving the original node order, so you must use a traversal that reflects the tree's structure (like preorder). This shows you read the problem carefully and avoid a common pitfall.
Confirm what 'original node order' means: the order in which nodes appear in a traversal of the tree (e.g., preorder). Ensure the subsequence must be increasing in value and preserve that order.
Select a traversal that captures the original order, such as preorder (root, left, right). Explain why inorder is not suitable because it sorts the values.
Perform the chosen traversal to produce a list of node values in the required order.
Use the standard O(n log n) patience sorting algorithm (with binary search) to find the length of the longest increasing subsequence in the extracted list.
State time and space complexity (O(n log n) time, O(n) space). Discuss edge cases like empty tree, single node, or duplicate values (if allowed).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.