evinda
Gold Member
MHB
- 3,741
- 0
I like Serena said:I have lost the context, which is probably somewhere far back in this thread. (Blush)
What is the context? (Wondering)
We want to check if all the leaves of the ordered tree are at the same depth.
Code:
1.currentDepth=0;
2. treeDepth = 0;
3. traverseTree(node)
4. if node = NULL
5. if (treeDepth = 0)
6. treeDepth = currentDepth;
7. return success
8. else if (treeDepth != currentDepth)
9. return failure
10. else
11. return success
12. for each child of node
13. currentDepth++
14. result = traverseTree(child)
15. currentDepth--
16. if result is failure
17. return failure
18. return success
I wanted to trace this algorithm for the tree of post #25.
At the beginning, we get that the depth of the tree is 6, but, actually it is 5, or not?
