Reputation: 91959
What do we mean by length of binary tree - number of nodes, or height of tree?
Thank you
Upvotes: 0
Views: 1817
Reputation: 107
I am going to argue that the n, number of nodes is the "best" answer.
Almost any recursively consistent measure might be argued as a potential answer, e.g. height. However, size of tree=n, number of nodes is the largest numerical answer.
Height of tree=log n, and the others will all be same or smaller numbers. So I conclude that node-count "should" be the length of a tree. It carries the most bits of information of the arguable possibilities.
Upvotes: 0
Reputation: 12561
Typically, 'length' refers to the number of items in the underlying data structure. The height of the tree would be its 'depth'
Upvotes: 0
Reputation: 2033
I would personally think of 'length' as the height (depth), not the size (# of nodes) of the tree, but this is quite a contextual question.
Upvotes: 1
Reputation: 20878
It is not a term I have seen used to describe the properties of a binary tree. I would guess someone using it would be referring to the depth.
Upvotes: 1