Practice
Learn
← Quit
0 / 0 correct
Data Structures
Hard
1 of 353
How do you find the lowest common ancestor of two nodes in a BST in O(h)?
A
Walk from the root: go left if both keys are smaller, right if both are larger, otherwise the current node is the LCA
B
Collect both paths and compare all pairs
C
Sort all nodes
D
Use BFS over the whole tree