我正在查看 Programming Interviews Exposed 中的以下代码,我似乎无法理解它是如何工作的。这个方法不会总是返回null吗?
// Overload it to handle nodes as well
Node findLowestCommonAncestor( Node root, Node child1,
Node child2 ){
if( root == null || child1 == null || child2 == null ){
return null;
}
return findLowestCommonAncestor( root, child1.getValue(),
child2.getValue() );
}