A question on getting number of nodes in a Binary Tree
- by Robert
Dear all,
I have written up two functions (pseudo code) for calculation the number of nodes and the tree height of a Binary Tree,given the root of the tree.
Most importantly,the Binary Tree is represented as the First chiled/next sibling format.
so
struct TreeNode
{
Object element;
TreeNode *firstChild;
TreeNode *nextSibling;
}
Calculate…