I'm wondering what the consensus is on the definition of "ancestor" in a computer science context.
I only ask because in Introduction to Algorithms, Second Edition, p. 259 there is a description of the algorithm Tree-Successor(x)
that seems odd. In finding the successor of node x,
[...] if the right subtree of node x is empty and x has a successor y, then y is the lowest ancestor of x whose left child is also an ancestor of x.
In a binary search tree with a root having key 2
and children 1
and 3
, the successor of 1
is its parent 2
. In this case, x is the left child of x's successor, y. According to the book's definition, then, x must be its own ancestor, unless I'm missing something.
I haven't found anything in the errata about this.