I have a tree data structure with N first-level child nodes that have childs too.
For example:
- Root
- Node1
- Node11
- Node111
- Node1111
- Node12
- Node2
- Node21
- Node211
I would like to know which of the braches has the biggest depth. As in the previous example it will be
Node1 – Node11 – Node111 – Node1111
that has a depth of four levels.
Any suggestion?
Thanks!
You must check all nodes. Several months ago I implemented this algorithm in this way:
Example test:
Console output: