Depth and height are properties of a node:
- The depth of a node is the number of edges from the node to the tree’s root node.
A root node will have a depth of 0.
- The height of a node is the number of edges on the longest path from the node to a leaf.
A leaf node will have a height of 0.
Properties of a tree:
- The height of a tree would be the height of its root node,
or equivalently, the depth of its deepest node.
- Note that depth doesn’t make sense for a tree.
- The diameter (or width) of a tree is the number of nodes on the longest path between any two leaf nodes. The tree below has a diameter of 6 nodes.