Height of a node in a binary tree
Hello,
I have a question regarding the height of a node in a binary tree other than the root node? In my height method, for the root i can pass the root as a parameter. But if i want to find the height of a node other than the root , what shud i pass as a parameter in that function?? Would really appreciate your help!!
Re: Height of a node in a binary tree
Why not the node itself? I presume the nodes in the tree have references to their parent.
Re: Height of a node in a binary tree
Good start, so far!
What you need:
- the height of a node
What you have:
- passing in the root as parameter
What you are missing:
... because it is a recursive method, in each method call, you need to keep track of the CURRENT height somehow, right? So... what are you missing??