← Questions

Lowest common ancestor in a BST and in a binary tree

0
MicrosoftCodingLast asked Jun 2026

Given two nodes, return their lowest common ancestor first in a binary search tree, using the ordering, and then in a plain binary tree where you cannot rely on it. Explain both recursions, the iterative BST version, and what changes if a node might be missing from the tree.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding