Hello everyone. I'm working on an urgent project with binary trees. I'm a little bit confused with the terminology. Can anybody please explain and give exact and clear definitions to full, perfect, complete, strict binary trees. I'm sure I'll easily work the algorithms out myself, the whole problem is that various sources give diverse definitions and it seems complicating.
Thanks in advance.
Ok now I'm stuck in here. I wanna check if a tree is complete, that is to say, all the nodes exist till the last level, in the last level all the nodes are as far left as possible. I should work out a recursive way. How should I act here? ( The other codes are already written, like checking a tree where all the nodes exist and the one where each node is either a leaf or has 2 sons )
Now what ideas about this one left?
So, sorry to post back so late. Did you ever figure this one out?
I dislike these kinds of problems, because it takes some careful thinking that the beginner is unaccustomed to.
The problem with the recursive solution is that it takes an additional state value that is not bound by the recursion frame.
It is also best written for understanding using multiple functions, but best optimized using a single function and a complicated state. (Easy: O(n²); Optimal: O(n).)