I need help with this problem. Example tree:
A
/
B-C-D
/
E-F-G
I have a binary tree that represents ordered tree and I have to count the number of children for each node and place that number in corresponding node.
There are three children(B,C,D) for A and three(E,F,G) for D. Zero children for B,C,E,F,G.
Every node only can have two children in physical (binary) representation. If a node has a left child then every right child from this node on is considered a child too. In my example A left child is B. B has one right child C. C has one right child D. So B, C and D are children for A in this task..
At the end of the program the data in nodes should be A(3),B(0),C(0),D(3),E(0),F(0),G(0).