DSA Studio
Search
Home
Sign in
Binary Trees Checkpoint
Tree recursion, traversals, BST validation, and LCA.
1. What should a tree recursion function return for a nil node?
A base case value (e.g., 0 for depth)
An error
The parent node
nil
2. Which traversal visits nodes in sorted order for a BST?
Inorder
Preorder
Postorder
Level-order
3. The naive BST validation (check left.val < root.val < right.val) is wrong because:
4. In LCA, if both left and right recursive calls return non-null:
Current node is the LCA
Return left result
Return right result
Return nil
5. Time complexity of visiting all n nodes in a tree?
Submit quiz
Auto-advance on pass