Height of the tree

Problem description

A tree has N nodes, and the first node is the root node.

Input:

The first line is an integer N indicating the number of nodes.

For each of the next few lines, there are two integers, i.e., a, b. Note that b is a child of a.

Output:

Please output the height of this tree (note that the root node is the first layer).

Link to original Problem? :slight_smile:

2 Likes

I just need an idea on how i can work that out. I am new in the field.

Depth-First-Search

1 Like