What is Tree Depth and height?

Asked

Viewed 146 times

7

I asked the question What is Breadth First and Depth First?. Perhaps a slightly simpler subject matter would be what are the depth and height of a tree structure. And why this matters in the data structure and affects the algorithm that crosses the tree?

  • Depth of a node is defined as the amount of edges that bind the node in question to the root node. The height of a tree is the amount of edges in the longest path starting from the root node to its leaves. The tree topology can favor one or the other algorithm. Higher height with fewer siblings at each level or the other way around. An unbalanced tree can negatively affect the performance of search algorithms.

  • @anonymousreply.

  • Making it clear that despite collaborating with the contest, I am not a candidate for the award.

1 answer

5

A tree has height ('height') and diameter the width ('Diameter' the 'width').

  • Height - The number of edges on the course between the root node and the most distant leaf node. The height of the tree below is 3. (Sometimes people increase 1 by counting the tree levels instead of the edges.)

  • Diameter - The number of nodes in the longest course in the tree. The tree below has a 6-metre radius.

The nodes of the tree have height (height) and profuseness (Depth).

  • Height - The number of edges on the course between this node and the farthest leaf node below this node. (The height of the root node is the same as the height of the tree.)

  • Depth - The number of edges on the course between this node and the root node.

Árvore com alturas e profudidades.

The solid orange node is the root node ('root Node'), the gray nodes are the inner nodes ('Inner nodes'), and the nodes with orange lines are the leaf nodes ('Leaf nodes'').

I found the image in this reply to What is the Difference between Tree Depth and height

Browser other questions tagged

You are not signed in. Login or sign up in order to post.