Given a tree
(0,1)
(0,7)
(0,12)
(0,13)
(0,15)
(1,2)
(1,4)
(1,6)
(1,7)
(2,3)
(2,5)
(2,6)
(3,4)
(3,5)
(7,8)
(8,9)
(8,10)
(8,11)
(9,10)
(9,11)
(12,13)
(13,14)
(13,15)
0 represents the root node, and each array represents whether there are directed edges between the two nodes. How do I tell if a node is the ancestor of another node? Thank you |