I predict that the answer will involve recursion.
But I don't really understand your example. Your tree contains 4 leaves, but line 3 contains only 3 zeros.
I predict that the answer will involve recursion.
But I don't really understand your example. Your tree contains 4 leaves, but line 3 contains only 3 zeros.
Sorry, I forgot to mention, the well formed parentheses form doesn't contain the last leaf. In this example *7 is the additional leaf.
and this is a typo: "My question is, how create from 1100100 to .." it is "...from 110100 to.."
Well, let's see. For this simple case, when you see a "(" you create a node, link it to the prior node, and make it the new "prior" node. When you see a ")" you create a leaf node, link it to the "prior" node, but don't make it the new "prior" node.
But I'm not sure that algorithm works for more complex cases.
Bookmarks