# Can a node of Radix tree which represents a valid key have one child?

Wikipedia says:

a radix tree is a data structure that represents a space-optimized trie (prefix tree) in which each node that is the only child is merged with its parent.

Now they are situations where the parent of the child represent a valid key in the data set like this example:

from this answer. Obviously you can't merge "smiles" into "smiled" and "smile" or you are going to lose valid entries in your data set.

Here as much as I understood suggests, as seen in the image,:

that for a one child parent with valid key like "organ" to add a child which has the same value (but it is not a parent). When the parent gets two children then that auxiliary child can be removed.

This implementation however for example doesn't seem to care about breaking the "no parent with one child" rule, while adding a child node to a leaf.

So my question is that whether "no parent with on child" rule is coined into the definition of radix tree and if so what is the computational/space advantage of it. It seems to me the 4 solution to keep up with the rule leads in both space and computational efficiency lost. If not then is it safe to say that Wikipedia definition need to be corrected?

I've used patricia tries extensively, but haven't implemented a radix=2 patricia tree. (I generally used radix=256.)

So my question is that whether "no parent with on child" rule is coined into the definition of radix tree

Not that I'm aware of. That sounds like an detail of a particular implementation.

Any time you have a valid key, you have a node. Any time you have a longer key that starts with that key, you have a child. So there will be lots of cases (on the order of some log function) of parents with one child, but those parents that have one child will imply a valid key in most implementations.

In your example, "smile" and "smiled" are two nodes, and "smiled" is a child of "smile". Both are valid keys. The "smile" node would have one child, "smiled".

Note that if a parent has only one child (e.g. after a node removal), and the parent does not represent a valid key, then the parent can combine itself with that one child. (That is an implementation choice.) So in your example, if we remove the key "smile", then we can either mark that node as "not holding a key any longer", or we can get rid of it, sliding the "smile" node up the tree.