Home c Depth and Height Supported

# Depth and Height Supported

Author

Date

Category

What is the difference between the depth and height of the support? Could you give an example of the depth and height of the substrance algorithm.

Well, actually:

• Support depth – distance from tree root to root support

• The support height is the length of the longest branch in this subtree; where the length of the branch of the subsection is the distance from the root of subtree to the sheet of this branch; Sheet suckling knot has no descendants)

Height Search Algorithm.

``````int heightoftree (BinaryTreenode * Node)
{
if (node ​​== 0)
Return 0;
int left, right;
If (node- & gt; leftchild! = NULL) {
Left = Heightoftree (Node- & gt; leftchild);
} ELSE.
left = -1;
If (node- & gt; rightchild! = NULL) {
Right = Heightoftree (Node- & GT; RightChild);
} ELSE.
Right = -1;
INT MAX = Left & GT; Right? Left: Right;
RETURN MAX + 1;
}
``````

Depth search algorithm.

``````int depthoftree (binarytreenode * node)
{
if (node- & gt; parent == null)
Return 0;
Return 1 + Depthoftree (Node- & GT; Parent);
}
``````

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.