Editing Lowest common ancestor
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 5: | Line 5: | ||
# <math>\operatorname{LCA}(\{u\}) = u</math>. | # <math>\operatorname{LCA}(\{u\}) = u</math>. | ||
# <math>u</math> is an ancestor of <math>v</math> if and only if <math>\operatorname{LCA}(u,v) = u</math>. | # <math>u</math> is an ancestor of <math>v</math> if and only if <math>\operatorname{LCA}(u,v) = u</math>. | ||
− | # If neither <math>u</math> nor <math>v</math> is an ancestor of the other, than <math>u</math> and <math>v</math> lie in different immediate subtrees of <math>\operatorname{LCA}(u,v)</math>. (That is, the child of the <math>\operatorname{LCA}(u,v)</math> of which <math>u</math> is a descendant is not the same as the child of the | + | # If neither <math>u</math> nor <math>v</math> is an ancestor of the other, than <math>u</math> and <math>v</math> lie in different immediate subtrees of <math>\operatorname{LCA}(u,v)</math>. (That is, the child of the <math>\operatorname{LCA}(u,v)</math> of which <math>u</math> is a descendant is not the same as the child of the LCA of which <math>v</math> is a descendant.) Furthermore, the LCA is the only node in the tree for which this is true. |
# The entire set of common ancestors of <math>S</math> is given by <math>\operatorname{LCA}(S)</math> and all of its ancestors (all the way up to the root of the tree). In particular, every common ancestor of <math>S</math> is an ancestor of <math>\operatorname{LCA}(S)</math>. | # The entire set of common ancestors of <math>S</math> is given by <math>\operatorname{LCA}(S)</math> and all of its ancestors (all the way up to the root of the tree). In particular, every common ancestor of <math>S</math> is an ancestor of <math>\operatorname{LCA}(S)</math>. | ||
# <math>\operatorname{LCA}(S)</math> precedes all nodes in <math>S</math> in the tree's preordering, and follows all nodes in <math>S</math> in the tree's postordering. | # <math>\operatorname{LCA}(S)</math> precedes all nodes in <math>S</math> in the tree's preordering, and follows all nodes in <math>S</math> in the tree's postordering. |