I have need to create a non-binary tree structure whose max depth needs to be restricted at all times. So, if I needed the depth to be restricted to say 3 and I tried to insert a node
at the leaf that's already at depth=3, it should fail.
Is there an algorithm that works on similar lines? So in my example, the algorithm should basically help me keep the tree at 3 levels at all times.
Thanks in advance
Edited by: user3214090 on Mar 9, 2011 1:19 PM
Nope. See Wikipedia for instance.
@OP: why do you need this? It's a very strange requirement. Basically that is going to put an upper bound on the number of nodes you can add to the tree, unless the number of children per parent is infinite, which would make for a degenerate tree that behaves more like a few lists. It seems a pointless restriction.