Quoting from wikipedia:
The *depth* (or *height*) of a tree is the length of the path from the root
to the deepest node in the tree.

However notice *length *is not defined and is left on the intuition.So *both
answers 2 and 3 are correct if we follow the above definition.* However the
next line on wiki entry says "*A (rooted) tree with only one node (the
root) has a depth of zero." **So this line suggests the height should be 2.
*But in either case I don't think any sane computer scientist/programmer
will worry about whether the answer should be 2 or 3.After all the answer
differs by a constant factor.All depends on how you want to implement
it.Somewhat similar question can be whether 0 is a positive number?
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com



On Sun, Mar 11, 2012 at 12:44 PM, rahul sharma <[email protected]>wrote:

> but according to the o/p it should be 3....i also concerned from the data
> structure and algo book it is also giving same answer.....so the
> height/depth is the number of nodes in largest path????is it rigt???
>
>
> On Sun, Mar 11, 2012 at 12:10 PM, Sonia Keys <[email protected]> wrote:
>
>> Correct is always whatever the specification says.  You may think
>> something else is more conventional, or something else may seem right to
>> you, but none of that matters if there are clear instructions otherwise.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/xmJbzvy_X6sJ.
>>
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to