google-deepmind/tree

find parent

Closed this issue · 2 comments

Hi. can you explain to me how can find a common parent for each node?

Since nodes in dm-tree are native collections and don't have a parent property, you'd need to convert it to our own graph data structure first. This is not offered by the API of this library.

If you are looking for inspiration in implementing such algorithm, see discussions / solutions to related problem on sites like leetcode.com

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/

thank you i do it.