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.
Answer 1, Authority 100%
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)
Answer 2, Authority 80%
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);
}